MCPcopy Create free account
hub / github.com/elimity-com/scim / TestScimErrorMarshalling

Function TestScimErrorMarshalling

errors/errors_test.go:67–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func 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}

Callers

nothing calls this directly

Calls 1

ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…