(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func TestScimErrorMarshalling(t *testing.T) { |
| 68 | scimErr := ScimError{ |
| 69 | ScimType: ScimTypeTooMany, |
| 70 | Detail: "Just too many.", |
| 71 | Status: http.StatusTooManyRequests, |
| 72 | } |
| 73 | |
| 74 | raw, err := json.Marshal(scimErr) |
| 75 | if err != nil { |
| 76 | t.Error(err) |
| 77 | } |
| 78 | |
| 79 | var s struct { |
| 80 | Schemas []string `json:"schemas"` |
| 81 | } |
| 82 | if err := json.Unmarshal(raw, &s); err != nil { |
| 83 | t.Error(err) |
| 84 | } |
| 85 | |
| 86 | if len(s.Schemas) != 1 || s.Schemas[0] != "urn:ietf:params:scim:api:messages:2.0:Error" { |
| 87 | t.Errorf("did not get the correct schemas") |
| 88 | } |
| 89 | |
| 90 | var e ScimError |
| 91 | if err := json.Unmarshal(raw, &e); err != nil { |
| 92 | t.Error(err) |
| 93 | } |
| 94 | |
| 95 | if e.ScimType != scimErr.ScimType { |
| 96 | t.Errorf("got invalid scim type: %s", e.ScimType) |
| 97 | } |
| 98 | |
| 99 | if e.Detail != scimErr.Detail { |
| 100 | t.Errorf("got invalid detail: %s", e.Detail) |
| 101 | } |
| 102 | |
| 103 | if e.Status != scimErr.Status { |
| 104 | t.Errorf("got invalid status: %d", e.Status) |
| 105 | } |
| 106 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…