diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-02-06 13:42:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-06 13:42:47 +0100 |
commit | d321c5d942f85b56852532edfd225dcdd591f817 (patch) | |
tree | 30ad98bcc2c2dd1136f46a48cbc44d422adfa184 /vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go | |
parent | 314e1a9c5a2041d2263bb74f1d21aa2798154d76 (diff) | |
parent | 9ac0ebb0791851aea81ecc847802db5a39bfb6e7 (diff) | |
download | podman-d321c5d942f85b56852532edfd225dcdd591f817.tar.gz podman-d321c5d942f85b56852532edfd225dcdd591f817.tar.bz2 podman-d321c5d942f85b56852532edfd225dcdd591f817.zip |
Merge pull request #2259 from vrothberg/vendor-check
Vendor check
Diffstat (limited to 'vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go')
-rw-r--r-- | vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go new file mode 100644 index 000000000..e42dd8a6e --- /dev/null +++ b/vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go @@ -0,0 +1,72 @@ +package matchers_test + +import ( + "errors" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/matchers" + "regexp" +) + +func Erroring() error { + return errors.New("bam") +} + +func NotErroring() error { + return nil +} + +type AnyType struct{} + +func Invalid() *AnyType { + return nil +} + +var _ = Describe("Succeed", func() { + It("should succeed if the function succeeds", func() { + Expect(NotErroring()).Should(Succeed()) + }) + + It("should succeed (in the negated) if the function errored", func() { + Expect(Erroring()).ShouldNot(Succeed()) + }) + + It("should not if passed a non-error", func() { + success, err := (&SucceedMatcher{}).Match(Invalid()) + Expect(success).Should(BeFalse()) + Expect(err).Should(MatchError("Expected an error-type. Got:\n <*matchers_test.AnyType | 0x0>: nil")) + }) + + It("doesn't support non-error type", func() { + success, err := (&SucceedMatcher{}).Match(AnyType{}) + Expect(success).Should(BeFalse()) + Expect(err).Should(MatchError("Expected an error-type. Got:\n <matchers_test.AnyType>: {}")) + }) + + It("doesn't support non-error pointer type", func() { + success, err := (&SucceedMatcher{}).Match(&AnyType{}) + Expect(success).Should(BeFalse()) + Expect(err).Should(MatchError(MatchRegexp(`Expected an error-type. Got:\n <*matchers_test.AnyType | 0x[[:xdigit:]]+>: {}`))) + }) + + It("should not succeed with pointer types that conform to error interface", func() { + err := &CustomErr{"ohai"} + Expect(err).ShouldNot(Succeed()) + }) + + It("should succeed with nil pointers to types that conform to error interface", func() { + var err *CustomErr = nil + Expect(err).Should(Succeed()) + }) + + It("builds failure message", func() { + actual := Succeed().FailureMessage(errors.New("oops")) + actual = regexp.MustCompile(" 0x.*>").ReplaceAllString(actual, " 0x00000000>") + Expect(actual).To(Equal("Expected success, but got an error:\n <*errors.errorString | 0x00000000>: {s: \"oops\"}\n oops")) + }) + + It("builds negated failure message", func() { + actual := Succeed().NegatedFailureMessage(123) + Expect(actual).To(Equal("Expected failure, but got no error.")) + }) +}) |