-
Notifications
You must be signed in to change notification settings - Fork 526
Expand file tree
/
Copy pathvacuum_stats_test.go
More file actions
48 lines (44 loc) · 1.26 KB
/
Copy pathvacuum_stats_test.go
File metadata and controls
48 lines (44 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package vacuum_stats
import (
"context"
"testing"
"github.com/jackc/pgconn"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"github.com/supabase/cli/internal/db/reset"
"github.com/supabase/cli/internal/utils"
"github.com/supabase/cli/pkg/pgtest"
)
var dbConfig = pgconn.Config{
Host: "127.0.0.1",
Port: 5432,
User: "admin",
Password: "password",
Database: "postgres",
}
func TestVacuumCommand(t *testing.T) {
t.Run("inspects vacuum stats", func(t *testing.T) {
// Setup in-memory fs
fsys := afero.NewMemMapFs()
// Setup mock postgres
conn := pgtest.NewConn()
defer conn.Close(t)
conn.Query(VacuumStatsQuery, reset.LikeEscapeSchema(utils.InternalSchemas)).
Reply("SELECT 1", Result{
Name: "test_schema.test_table",
Last_vacuum: "2021-01-01 00:00:00",
Last_autovacuum: "2021-01-01 00:00:00",
Last_analyze: "2021-01-01 00:00:00",
Last_autoanalyze: "2021-01-01 00:00:00",
Rowcount: "1000",
Dead_rowcount: "100",
Autovacuum_threshold: "100",
Expect_autovacuum: "yes",
Expect_autoanalyze: "yes",
})
// Run test
err := Run(context.Background(), dbConfig, fsys, conn.Intercept)
// Check error
assert.NoError(t, err)
})
}