forked from oauth2-proxy/oauth2-proxy
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
pkg/apis/options/loadtest/options_matcher.go → pkg/apis/options/testutil/options_matcher.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package loadtest | ||
package testutil | ||
|
||
import ( | ||
"errors" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package testutil | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Options Gomega Matcher", func() { | ||
type TestOptions struct { | ||
Foo string | ||
Bar int | ||
List []string | ||
|
||
// unexported fields should be ignored | ||
unexported string | ||
another string | ||
} | ||
|
||
Context("two empty option structs are equal", func() { | ||
Expect(EqualOpts(TestOptions{}).Match(TestOptions{})).To(BeTrue()) | ||
}) | ||
|
||
Context("two options with the same content should be equal", func() { | ||
opt1 := TestOptions{Foo: "foo", Bar: 1} | ||
opt2 := TestOptions{Foo: "foo", Bar: 1} | ||
Expect(EqualOpts(opt1).Match(opt2)).To(BeTrue()) | ||
}) | ||
|
||
Context("when two options have different content", func() { | ||
opt1 := TestOptions{Foo: "foo", Bar: 1} | ||
opt2 := TestOptions{Foo: "foo", Bar: 2} | ||
Expect(EqualOpts(opt1).Match(opt2)).To(BeFalse()) | ||
}) | ||
|
||
Context("when two options have different types they are not equal", func() { | ||
opt1 := TestOptions{Foo: "foo", Bar: 1} | ||
opt2 := struct { | ||
Foo string | ||
Bar int | ||
}{ | ||
Foo: "foo", | ||
Bar: 1, | ||
} | ||
Expect(EqualOpts(opt1).Match(opt2)).To(BeFalse()) | ||
}) | ||
|
||
Context("when two options have different unexported fields they are equal", func() { | ||
opts1 := TestOptions{Foo: "foo", Bar: 1, unexported: "unexported", another: "another"} | ||
opts2 := TestOptions{Foo: "foo", Bar: 1, unexported: "unexported2"} | ||
Expect(EqualOpts(opts1).Match(opts2)).To(BeTrue()) | ||
}) | ||
|
||
Context("when two options have different list content they are not equal", func() { | ||
opt1 := TestOptions{List: []string{"foo", "bar"}} | ||
opt2 := TestOptions{List: []string{"foo", "baz"}} | ||
Expect(EqualOpts(opt1).Match(opt2)).To(BeFalse()) | ||
}) | ||
|
||
Context("when two options have different list lengths they are not equal", func() { | ||
opt1 := TestOptions{List: []string{"foo", "bar"}} | ||
opt2 := TestOptions{List: []string{"foo", "bar", "baz"}} | ||
Expect(EqualOpts(opt1).Match(opt2)).To(BeFalse()) | ||
}) | ||
|
||
Context("when one options has a list of length 0 and the other is nil they are equal", func() { | ||
otp1 := TestOptions{List: []string{}} | ||
opt2 := TestOptions{} | ||
Expect(EqualOpts(otp1).Match(opt2)).To(BeTrue()) | ||
}) | ||
}) |