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

Function TestPostgresParameters

internal/patroni/postgres_test.go:101–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

99}
100
101func TestPostgresParameters(t *testing.T) {
102 t.Run("Zero", func(t *testing.T) {
103 result := PostgresParameters(nil)
104
105 assert.Assert(t, result != nil)
106 assert.DeepEqual(t, result.AsMap(), map[string]string{})
107 })
108
109 t.Run("NoDynamicConfig", func(t *testing.T) {
110 spec := new(v1beta1.PatroniSpec)
111 result := PostgresParameters(spec)
112
113 assert.Assert(t, result != nil)
114 assert.DeepEqual(t, result.AsMap(), map[string]string{})
115 })
116
117 t.Run("NoPostgreSQL", func(t *testing.T) {
118 spec := new(v1beta1.PatroniSpec)
119 require.UnmarshalInto(t, spec, `{
120 dynamicConfiguration: {},
121 }`)
122 result := PostgresParameters(spec)
123
124 assert.Assert(t, result != nil)
125 assert.DeepEqual(t, result.AsMap(), map[string]string{})
126 })
127
128 t.Run("WrongPostgreSQLType", func(t *testing.T) {
129 spec := new(v1beta1.PatroniSpec)
130 require.UnmarshalInto(t, spec, `{
131 dynamicConfiguration: {
132 postgresql: asdf,
133 },
134 }`)
135 result := PostgresParameters(spec)
136
137 assert.Assert(t, result != nil)
138 assert.DeepEqual(t, result.AsMap(), map[string]string{})
139 })
140
141 t.Run("NoParameters", func(t *testing.T) {
142 spec := new(v1beta1.PatroniSpec)
143 require.UnmarshalInto(t, spec, `{
144 dynamicConfiguration: {
145 postgresql: {
146 use_pg_rewind: true,
147 },
148 },
149 }`)
150 result := PostgresParameters(spec)
151
152 assert.Assert(t, result != nil)
153 assert.DeepEqual(t, result.AsMap(), map[string]string{})
154 })
155
156 t.Run("WrongParametersType", func(t *testing.T) {
157 spec := new(v1beta1.PatroniSpec)
158 require.UnmarshalInto(t, spec, `{

Callers

nothing calls this directly

Calls 3

UnmarshalIntoFunction · 0.92
PostgresParametersFunction · 0.85
AsMapMethod · 0.80

Tested by

no test coverage detected