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

Function TestPostgreSQLHBA

internal/pgmonitor/postgres_test.go:18–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestPostgreSQLHBA(t *testing.T) {
19 ctx := context.Background()
20
21 t.Run("ExporterDisabled", func(t *testing.T) {
22 inCluster := &v1beta1.PostgresCluster{}
23 outHBAs := postgres.HBAs{}
24 PostgreSQLHBAs(ctx, inCluster, &outHBAs)
25 assert.Equal(t, len(outHBAs.Mandatory), 0)
26 })
27
28 t.Run("ExporterEnabled", func(t *testing.T) {
29 inCluster := &v1beta1.PostgresCluster{}
30 inCluster.Spec.Monitoring = &v1beta1.MonitoringSpec{
31 PGMonitor: &v1beta1.PGMonitorSpec{
32 Exporter: &v1beta1.ExporterSpec{
33 Image: "image",
34 },
35 },
36 }
37
38 outHBAs := postgres.HBAs{}
39 PostgreSQLHBAs(ctx, inCluster, &outHBAs)
40
41 assert.Equal(t, len(outHBAs.Mandatory), 3)
42 assert.Equal(t, outHBAs.Mandatory[0].String(), `host all "ccp_monitoring" "127.0.0.0/8" "scram-sha-256"`)
43 assert.Equal(t, outHBAs.Mandatory[1].String(), `host all "ccp_monitoring" "::1/128" "scram-sha-256"`)
44 assert.Equal(t, outHBAs.Mandatory[2].String(), `host all "ccp_monitoring" all "reject"`)
45 })
46}
47
48func TestPostgreSQLParameters(t *testing.T) {
49 ctx := context.Background()

Callers

nothing calls this directly

Calls 3

PostgreSQLHBAsFunction · 0.85
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected