-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vendor: clean up dependencies (#173)
* vendor: remove stray github.com/Sirupsen/logrus * vendor: remove common lib
- Loading branch information
Showing
6 changed files
with
68 additions
and
14 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
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
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,49 @@ | ||
package fosite | ||
|
||
import "testing" | ||
import "github.com/oleiade/reflections" | ||
import "github.com/stretchr/testify/assert" | ||
import "github.com/stretchr/testify/require" | ||
|
||
func AssertObjectKeysEqual(t *testing.T, a, b interface{}, keys ...string) { | ||
assert.True(t, len(keys) > 0, "No keys provided.") | ||
for _, k := range keys { | ||
c, err := reflections.GetField(a, k) | ||
assert.Nil(t, err) | ||
d, err := reflections.GetField(b, k) | ||
assert.Nil(t, err) | ||
assert.Equal(t, c, d, "%s", k) | ||
} | ||
} | ||
|
||
func AssertObjectKeysNotEqual(t *testing.T, a, b interface{}, keys ...string) { | ||
assert.True(t, len(keys) > 0, "No keys provided.") | ||
for _, k := range keys { | ||
c, err := reflections.GetField(a, k) | ||
assert.Nil(t, err) | ||
d, err := reflections.GetField(b, k) | ||
assert.Nil(t, err) | ||
assert.NotEqual(t, c, d, "%s", k) | ||
} | ||
} | ||
|
||
func RequireObjectKeysEqual(t *testing.T, a, b interface{}, keys ...string) { | ||
assert.True(t, len(keys) > 0, "No keys provided.") | ||
for _, k := range keys { | ||
c, err := reflections.GetField(a, k) | ||
assert.Nil(t, err) | ||
d, err := reflections.GetField(b, k) | ||
assert.Nil(t, err) | ||
require.Equal(t, c, d, "%s", k) | ||
} | ||
} | ||
func RequireObjectKeysNotEqual(t *testing.T, a, b interface{}, keys ...string) { | ||
assert.True(t, len(keys) > 0, "No keys provided.") | ||
for _, k := range keys { | ||
c, err := reflections.GetField(a, k) | ||
assert.Nil(t, err) | ||
d, err := reflections.GetField(b, k) | ||
assert.Nil(t, err) | ||
require.NotEqual(t, c, d, "%s", k) | ||
} | ||
} |
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,17 @@ | ||
package fosite | ||
|
||
import "testing" | ||
|
||
func TestAssertObjectsAreEqualByKeys(t *testing.T) { | ||
type foo struct { | ||
Name string | ||
Body int | ||
} | ||
a := &foo{"foo", 1} | ||
b := &foo{"bar", 1} | ||
c := &foo{"baz", 3} | ||
|
||
AssertObjectKeysEqual(t, a, a, "Name", "Body") | ||
AssertObjectKeysNotEqual(t, a, b, "Name") | ||
AssertObjectKeysNotEqual(t, a, c, "Name", "Body") | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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