MCPcopy Create free account
hub / github.com/prometheus/common / TestJSONMarshalSecret

Function TestJSONMarshalSecret

config/config_test.go:26–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func 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
60func TestHeaderHTTPHeader(t *testing.T) {
61 testcases := map[string]struct {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected