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

Function TestEnableInPostgreSQL

internal/pgaudit/postgres_test.go:19–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestEnableInPostgreSQL(t *testing.T) {
20 expected := errors.New("whoops")
21 exec := func(
22 _ context.Context, stdin io.Reader, stdout, stderr io.Writer, command ...string,
23 ) error {
24 assert.Assert(t, stdout != nil, "should capture stdout")
25 assert.Assert(t, stderr != nil, "should capture stderr")
26
27 assert.Assert(t, strings.Contains(strings.Join(command, "\n"),
28 `SELECT datname FROM pg_catalog.pg_database`,
29 ), "expected all databases and templates")
30
31 b, err := io.ReadAll(stdin)
32 assert.NilError(t, err)
33 assert.Equal(t, string(b), strings.Trim(`
34SET client_min_messages = WARNING; CREATE EXTENSION IF NOT EXISTS pgaudit;
35 `, "\t\n"))
36
37 return expected
38 }
39
40 ctx := context.Background()
41 assert.Equal(t, expected, EnableInPostgreSQL(ctx, exec))
42}
43
44func TestPostgreSQLParameters(t *testing.T) {
45 parameters := postgres.Parameters{

Callers

nothing calls this directly

Calls 2

EnableInPostgreSQLFunction · 0.70
EqualMethod · 0.45

Tested by

no test coverage detected