Skip to content

Commit

Permalink
Adds tests for etag()
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Moyer committed Mar 31, 2020
1 parent 28b9352 commit 97b01e9
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions pkg/scim/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,54 @@ func TestError(t *testing.T) {
}
}

func TestETag(t *testing.T) {
vers := "W\\/\"3694e05e9dff590\""
res := User{
CommonAttributes: CommonAttributes{
Meta: Meta{
Version: vers,
},
},
}

tests := []struct {
name string
disabled bool
}{
{"ETags disabled", true},
{"ETags enabled", false},
}

for idx := range tests {
test := tests[idx]
t.Run(test.name, func(t *testing.T) {
c := Client{
client: &client{
cfg: &clientCfg{
DisableEtag: test.disabled,
},
},
}

req := http.Request{
Header: map[string][]string{},
}

c.etag(&res, &req)

if test.disabled {
assert.NotContains(t, req.Header, "If-Match")
return
}

assert.Contains(t, req.Header, "If-Match")
exp := []string{}
exp = append(exp, vers)
assert.Equal(t, exp, req.Header["If-Match"])
})
}
}

func TestResourceOrError(t *testing.T) {
const minuser = `
{
Expand Down

0 comments on commit 97b01e9

Please sign in to comment.