(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func 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; |
| 32 | SET synchronous_commit = LOCAL; |
| 33 | CREATE EXTENSION IF NOT EXISTS postgis; |
| 34 | CREATE EXTENSION IF NOT EXISTS postgis_topology; |
| 35 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; |
| 36 | CREATE 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 | } |
nothing calls this directly
no test coverage detected