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

Function TestDynamicConfiguration

internal/patroni/config_test.go:219–540  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

217}
218
219func TestDynamicConfiguration(t *testing.T) {
220 t.Parallel()
221
222 parameters := func(in map[string]string) *postgres.ParameterSet {
223 out := postgres.NewParameterSet()
224 for k, v := range in {
225 out.Add(k, v)
226 }
227 return out
228 }
229
230 rules := func(in ...string) *postgres.OrderedHBAs {
231 out := new(postgres.OrderedHBAs)
232 out.AppendUnstructured(in...)
233 return out
234 }
235
236 for _, tt := range []struct {
237 name string
238 spec string
239 hbas *postgres.OrderedHBAs
240 params *postgres.ParameterSet
241 expected map[string]any
242 }{
243 {
244 name: "empty is valid",
245 expected: map[string]any{
246 "loop_wait": int32(10),
247 "ttl": int32(30),
248 "postgresql": map[string]any{
249 "use_pg_rewind": true,
250 "use_slots": false,
251 },
252 },
253 },
254 {
255 name: "top-level passes through",
256 spec: `{
257 patroni: {
258 dynamicConfiguration: {
259 retry_timeout: 5,
260 },
261 },
262 }`,
263 expected: map[string]any{
264 "loop_wait": int32(10),
265 "ttl": int32(30),
266 "retry_timeout": int64(5),
267 "postgresql": map[string]any{
268 "use_pg_rewind": true,
269 "use_slots": false,
270 },
271 },
272 },
273 {
274 name: "top-level: spec overrides input",
275 spec: `{
276 patroni: {

Callers

nothing calls this directly

Calls 6

AddMethod · 0.95
NewParameterSetFunction · 0.92
UnmarshalIntoFunction · 0.92
DynamicConfigurationFunction · 0.85
AppendUnstructuredMethod · 0.80
DefaultMethod · 0.45

Tested by

no test coverage detected