func()

in rocketmq-knative/source/pkg/controller/testing/table.go [162:180]


func (tc *TestCase) VerifyErr(err error) error {
	// A non-empty WantErrMsg implies that an error is wanted.
	wantErr := tc.WantErr || tc.WantErrMsg != ""

	if wantErr && err == nil {
		return fmt.Errorf("want error, got nil")
	}

	if !wantErr && err != nil {
		return fmt.Errorf("want no error, got %v", err)
	}

	if err != nil {
		if diff := cmp.Diff(tc.WantErrMsg, err.Error()); diff != "" {
			return fmt.Errorf("incorrect error (-want, +got): %v", diff)
		}
	}
	return nil
}