(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestJSONMarshalSecret(t *testing.T) { |
| 27 | type tmp struct { |
| 28 | S Secret |
| 29 | } |
| 30 | for _, tc := range []struct { |
| 31 | desc string |
| 32 | data tmp |
| 33 | expected string |
| 34 | }{ |
| 35 | { |
| 36 | desc: "inhabited", |
| 37 | // u003c -> "<" |
| 38 | // u003e -> ">" |
| 39 | data: tmp{"test"}, |
| 40 | expected: "{\"S\":\"\\u003csecret\\u003e\"}", |
| 41 | }, |
| 42 | { |
| 43 | desc: "empty", |
| 44 | data: tmp{}, |
| 45 | expected: "{\"S\":\"\"}", |
| 46 | }, |
| 47 | } { |
| 48 | t.Run(tc.desc, func(t *testing.T) { |
| 49 | c, err := json.Marshal(tc.data) |
| 50 | if err != nil { |
| 51 | t.Fatal(err) |
| 52 | } |
| 53 | if tc.expected != string(c) { |
| 54 | t.Fatalf("Secret not marshaled correctly, got '%s'", string(c)) |
| 55 | } |
| 56 | }) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | func TestHeaderHTTPHeader(t *testing.T) { |
| 61 | testcases := map[string]struct { |
nothing calls this directly
no outgoing calls
no test coverage detected