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

Function TestContext

internal/feature/features_test.go:52–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestContext(t *testing.T) {
53 t.Parallel()
54 gate := NewGate()
55 ctx := NewContext(context.Background(), gate)
56
57 assert.Equal(t, ShowAssigned(ctx), "")
58 assert.Assert(t, ShowEnabled(ctx) != "") // This assumes some feature is enabled by default.
59
60 assert.NilError(t, gate.Set("TablespaceVolumes=true"))
61 assert.Assert(t, Enabled(ctx, TablespaceVolumes))
62 assert.Equal(t, ShowAssigned(ctx), "TablespaceVolumes=true")
63 assert.Assert(t,
64 strings.Contains(ShowEnabled(ctx), "TablespaceVolumes=true"),
65 "got: %v", ShowEnabled(ctx))
66
67 assert.NilError(t, gate.SetFromMap(map[string]bool{TablespaceVolumes: false}))
68 assert.Assert(t, !Enabled(ctx, TablespaceVolumes))
69 assert.Equal(t, ShowAssigned(ctx), "TablespaceVolumes=false")
70 assert.Assert(t,
71 !strings.Contains(ShowEnabled(ctx), "TablespaceVolumes"),
72 "got: %v", ShowEnabled(ctx))
73}

Callers

nothing calls this directly

Calls 8

NewGateFunction · 0.85
ShowAssignedFunction · 0.85
ShowEnabledFunction · 0.85
EnabledFunction · 0.85
SetFromMapMethod · 0.80
NewContextFunction · 0.70
SetMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected