(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func 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(` |
| 34 | SET 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 | |
| 44 | func TestPostgreSQLParameters(t *testing.T) { |
| 45 | parameters := postgres.Parameters{ |
nothing calls this directly
no test coverage detected