MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / TestParameterSet

Function TestParameterSet

internal/postgres/parameters_test.go:37–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestParameterSet(t *testing.T) {
38 t.Run("NilAsMap", func(t *testing.T) {
39 m := (*ParameterSet)(nil).AsMap()
40 assert.Assert(t, m == nil)
41 })
42
43 t.Run("NilDeepCopy", func(t *testing.T) {
44 ps := (*ParameterSet)(nil).DeepCopy()
45 assert.Assert(t, ps == nil)
46 })
47
48 ps := NewParameterSet()
49
50 ps.Add("x", "y")
51 assert.Assert(t, ps.Has("X"))
52 assert.Equal(t, ps.Value("x"), "y")
53
54 v, ok := ps.Get("X")
55 assert.Assert(t, ok)
56 assert.Equal(t, v, "y")
57
58 ps.Add("X", "z")
59 assert.Equal(t, ps.Value("x"), "z")
60
61 ps.Add("abc", "j'l")
62 assert.DeepEqual(t, ps.AsMap(), map[string]string{
63 "abc": "j'l",
64 "x": "z",
65 })
66
67 ps2 := ps.DeepCopy()
68 assert.Assert(t, ps2.Has("abc"))
69 assert.Equal(t, ps2.Value("x"), ps.Value("x"))
70
71 ps2.Add("x", "n")
72 assert.Assert(t, ps2.Value("x") != ps.Value("x"))
73
74 assert.DeepEqual(t, ps.String(), ``+
75 `abc = 'j''l'`+"\n"+
76 `x = 'z'`+"\n")
77}
78
79func TestParameterSetAppendToList(t *testing.T) {
80 ps := NewParameterSet()

Callers

nothing calls this directly

Calls 10

AsMapMethod · 0.95
DeepCopyMethod · 0.95
AddMethod · 0.95
HasMethod · 0.95
ValueMethod · 0.95
GetMethod · 0.95
StringMethod · 0.95
NewParameterSetFunction · 0.85
HasMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected