Skip to content

Commit

Permalink
Add tests for User.IsEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Oct 27, 2022
1 parent 9e6aed5 commit 1c5ef06
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@ var (
generate = flag.Bool("gen", false, "generate missing .golden files")
)

func TestIsEmpty(t *testing.T) {
tests := []struct {
input User
want bool
}{
{input: User{}, want: true},
{input: User{ID: "foo"}, want: false},
{input: User{Email: "foo@example.com"}, want: false},
{input: User{IPAddress: "127.0.0.1"}, want: false},
{input: User{Username: "My Username"}, want: false},
{input: User{Name: "My Name"}, want: false},
{input: User{Segment: "My Segment"}, want: false},
{input: User{Data: map[string]string{"foo": "bar"}}, want: false},
{input: User{ID: "foo", Email: "foo@example.com", IPAddress: "127.0.0.1", Username: "My Username", Name: "My Name", Segment: "My Segment", Data: map[string]string{"foo": "bar"}}, want: false},
}

for _, test := range tests {
assertEqual(t, test.input.IsEmpty(), test.want)
}
}

func TestNewRequest(t *testing.T) {
const payload = `{"test_data": true}`
got := NewRequest(httptest.NewRequest("POST", "/test/?q=sentry", strings.NewReader(payload)))
Expand Down

0 comments on commit 1c5ef06

Please sign in to comment.