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

Function TestEnableInPostgreSQL

internal/postgis/postgis_test.go:17–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

EnableInPostgreSQLFunction · 0.70
EqualMethod · 0.45

Tested by

no test coverage detected