Repository: kubernetes/kubernetes
File: test/e2e/dra/test-driver/gomega/matchers.go (Go)

Code before:
			return true, nil
		}
	}
	return false, nil
}).WithMessage("contain successful NotifyRegistrationStatus call")

func GetInfoFailed() gcustom.CustomGomegaMatcher {
	return gcustom.MakeMatcher(func(actualCalls []testdriver.GRPCCall) (bool, error) {
		for _, call := range actualCalls {
			if call.FullMethod == "/pluginregistration.Registration/GetInfo" && call.Err != nil {
				return true, nil
			}
		}
		return false, nil
	}).WithMessage("contain unsuccessful GetInfo call")
}

// NodePrepareResoucesSucceeded checks that NodePrepareResources API has been called and succeeded
var NodePrepareResourcesSucceeded = gcustom.MakeMatcher(func(actualCalls []testdriver.GRPCCall) (bool, error) {
	for _, call := range actualCalls {
		if strings.HasSuffix(call.FullMethod, "/NodePrepareResources") && call.Response != nil && call.Err == nil {
			return true, nil
		}
	}
	return false, nil
}).WithMessage("contain successful NodePrepareResources call")

// NodePrepareResoucesFailed checks that NodePrepareResources API has been called and returned an error
var NodePrepareResourcesFailed = gcustom.MakeMatcher(func(actualCalls []testdriver.GRPCCall) (bool, error) {
	for _, call := range actualCalls {
		if strings.HasSuffix(call.FullMethod, "/NodePrepareResources") && call.Err != nil {
			return true, nil
		}
	}
	return false, nil
}).WithMessage("contain unsuccessful NodePrepareResources call")

// NodeUnprepareResoucesSucceeded checks that NodeUnprepareResources API has been called and succeeded
var NodeUnprepareResourcesSucceeded = gcustom.MakeMatcher(func(actualCalls []testdriver.GRPCCall) (bool, error) {
	for _, call := range actualCalls {
		if strings.HasSuffix(call.FullMethod, "/NodeUnprepareResources") && call.Response != nil && call.Err == nil {
			return true, nil
		}
	}
	return false, nil
}).WithMessage("contain successful NodeUnprepareResources call")

// NodeUnprepareResoucesFailed checks that NodeUnprepareResources API has been called and returned an error
var NodeUnprepareResourcesFailed = gcustom.MakeMatcher(func(actualCalls []testdriver.GRPCCall) (bool, error) {
	for _, call := range actualCalls {
		if strings.HasSuffix(call.FullMethod, "/NodeUnprepareResources") && call.Err != nil {

Review comment (bug):
I think this produces a better failure message:
```
return gomega.ContainElement(gstruct.MatchFields(gstruct.IgnoreExtra, gstruct.Fields{"FullMethod": gomega.Equal("/pluginregistration.Registration/NotifyRegistrationStatus"), "Err": gomega.Not(gomega.IsNil())}))
```

But it's not what we have used for the other checks, so feel free to ignore.


Code after:
			return true, nil
		}
	}
	return false, nil
}).WithMessage("contain successful NotifyRegistrationStatus call")

func GetInfoFailed() gcustom.CustomGomegaMatcher {
	return gcustom.MakeMatcher(func(actualCalls []testdriver.GRPCCall) (bool, error) {
		for _, call := range actualCalls {
			if call.FullMethod == "/pluginregistration.Registration/GetInfo" && call.Err != nil {
				return true, nil
			}
		}
		return false, nil
	}).WithMessage("contain unsuccessful GetInfo call")
}

func NotifyRegistrationStatusFailed() gcustom.CustomGomegaMatcher {
	return gcustom.MakeMatcher(func(actualCalls []testdriver.GRPCCall) (bool, error) {
		for _, call := range actualCalls {
			if call.FullMethod == "/pluginregistration.Registration/NotifyRegistrationStatus" && call.Err != nil {
				return true, nil
			}
		}
		return false, nil
	}).WithMessage("contain unsuccessful NotifyRegistrationStatus call")
}

// NodePrepareResoucesSucceeded checks that NodePrepareResources API has been called and succeeded
var NodePrepareResourcesSucceeded = gcustom.MakeMatcher(func(actualCalls []testdriver.GRPCCall) (bool, error) {
	for _, call := range actualCalls {
		if strings.HasSuffix(call.FullMethod, "/NodePrepareResources") && call.Response != nil && call.Err == nil {
			return true, nil
		}
	}
	return false, nil
}).WithMessage("contain successful NodePrepareResources call")

// NodePrepareResoucesFailed checks that NodePrepareResources API has been called and returned an error
var NodePrepareResourcesFailed = gcustom.MakeMatcher(func(actualCalls []testdriver.GRPCCall) (bool, error) {
	for _, call := range actualCalls {
		if strings.HasSuffix(call.FullMethod, "/NodePrepareResources") && call.Err != nil {
			return true, nil
		}
	}
	return false, nil
}).WithMessage("contain unsuccessful NodePrepareResources call")

// NodeUnprepareResoucesSucceeded checks that NodeUnprepareResources API has been called and succeeded
var NodeUnprepareResourcesSucceeded = gcustom.MakeMatcher(func(actualCalls []testdriver.GRPCCall) (bool, error) {
	for _, call := range actualCalls {