mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-10-19 05:39:51 +00:00
007988d1cb
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.27.8 to 1.27.10. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.27.8...v1.27.10) --- updated-dependencies: - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
41 lines
855 B
Go
41 lines
855 B
Go
// untested sections: 3
|
|
|
|
package matchers
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/onsi/gomega/format"
|
|
)
|
|
|
|
type BeAnExistingFileMatcher struct {
|
|
expected interface{}
|
|
}
|
|
|
|
func (matcher *BeAnExistingFileMatcher) Match(actual interface{}) (success bool, err error) {
|
|
actualFilename, ok := actual.(string)
|
|
if !ok {
|
|
return false, fmt.Errorf("BeAnExistingFileMatcher matcher expects a file path")
|
|
}
|
|
|
|
if _, err = os.Stat(actualFilename); err != nil {
|
|
switch {
|
|
case os.IsNotExist(err):
|
|
return false, nil
|
|
default:
|
|
return false, err
|
|
}
|
|
}
|
|
|
|
return true, nil
|
|
}
|
|
|
|
func (matcher *BeAnExistingFileMatcher) FailureMessage(actual interface{}) (message string) {
|
|
return format.Message(actual, "to exist")
|
|
}
|
|
|
|
func (matcher *BeAnExistingFileMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
|
return format.Message(actual, "not to exist")
|
|
}
|