diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2019-02-05 11:51:41 +0100 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2019-02-06 11:14:06 +0100 |
commit | 9ac0ebb0791851aea81ecc847802db5a39bfb6e7 (patch) | |
tree | 30ad98bcc2c2dd1136f46a48cbc44d422adfa184 /vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go | |
parent | 51714d5da7aaa19014fd67b48b79dfbd5f69c1f0 (diff) | |
download | podman-9ac0ebb0791851aea81ecc847802db5a39bfb6e7.tar.gz podman-9ac0ebb0791851aea81ecc847802db5a39bfb6e7.tar.bz2 podman-9ac0ebb0791851aea81ecc847802db5a39bfb6e7.zip |
Cirrus: add vendor_check_task
* Make sure that all vendored dependencies are in sync with the code and
the vendor.conf by running `make vendor` with a follow-up status check
of the git tree.
* Vendor ginkgo and gomega to include the test dependencies.
Signed-off-by: Chris Evic <cevich@redhat.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go')
-rw-r--r-- | vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go new file mode 100644 index 000000000..3ab991e4f --- /dev/null +++ b/vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go @@ -0,0 +1,80 @@ +package matchers_test + +import ( + "errors" + "strings" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/matchers" +) + +var _ = Describe("Equal", func() { + Context("when asserting that nil equals nil", func() { + It("should error", func() { + success, err := (&EqualMatcher{Expected: nil}).Match(nil) + + Expect(success).Should(BeFalse()) + Expect(err).Should(HaveOccurred()) + }) + }) + + Context("When asserting equality between objects", func() { + It("should do the right thing", func() { + Expect(5).Should(Equal(5)) + Expect(5.0).Should(Equal(5.0)) + + Expect(5).ShouldNot(Equal("5")) + Expect(5).ShouldNot(Equal(5.0)) + Expect(5).ShouldNot(Equal(3)) + + Expect("5").Should(Equal("5")) + Expect([]int{1, 2}).Should(Equal([]int{1, 2})) + Expect([]int{1, 2}).ShouldNot(Equal([]int{2, 1})) + Expect([]byte{'f', 'o', 'o'}).Should(Equal([]byte{'f', 'o', 'o'})) + Expect([]byte{'f', 'o', 'o'}).ShouldNot(Equal([]byte{'b', 'a', 'r'})) + Expect(map[string]string{"a": "b", "c": "d"}).Should(Equal(map[string]string{"a": "b", "c": "d"})) + Expect(map[string]string{"a": "b", "c": "d"}).ShouldNot(Equal(map[string]string{"a": "b", "c": "e"})) + Expect(errors.New("foo")).Should(Equal(errors.New("foo"))) + Expect(errors.New("foo")).ShouldNot(Equal(errors.New("bar"))) + + Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).Should(Equal(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}})) + Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "bar", n: 3, f: 2.0, arr: []string{"a", "b"}})) + Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "foo", n: 2, f: 2.0, arr: []string{"a", "b"}})) + Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "foo", n: 3, f: 3.0, arr: []string{"a", "b"}})) + Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b", "c"}})) + }) + }) + + Describe("failure messages", func() { + It("shows the two strings simply when they are short", func() { + subject := EqualMatcher{Expected: "eric"} + + failureMessage := subject.FailureMessage("tim") + Expect(failureMessage).To(BeEquivalentTo(expectedShortStringFailureMessage)) + }) + + It("shows the exact point where two long strings differ", func() { + stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + + subject := EqualMatcher{Expected: stringWithZ} + + failureMessage := subject.FailureMessage(stringWithB) + Expect(failureMessage).To(BeEquivalentTo(expectedLongStringFailureMessage)) + }) + }) +}) + +var expectedShortStringFailureMessage = strings.TrimSpace(` +Expected + <string>: tim +to equal + <string>: eric +`) +var expectedLongStringFailureMessage = strings.TrimSpace(` +Expected + <string>: "...aaaaabaaaaa..." +to equal | + <string>: "...aaaaazaaaaa..." +`) |