1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
10 "git.arvados.org/arvados.git/lib/config"
11 "git.arvados.org/arvados.git/sdk/go/arvadostest"
12 "git.arvados.org/arvados.git/sdk/go/ctxlog"
16 type railsDBSuite struct{}
18 var _ = check.Suite(&railsDBSuite{})
20 // Check services/api/db/migrate/*.rb match schema_migrations
21 func (s *railsDBSuite) TestMigrationList(c *check.C) {
22 var logbuf bytes.Buffer
23 log := ctxlog.New(&logbuf, "text", "info")
24 todo, err := migrationList("../../services/api", log)
25 c.Check(err, check.IsNil)
26 c.Check(todo["20220804133317"], check.Equals, true)
27 c.Check(logbuf.String(), check.Equals, "")
29 cfg, err := config.NewLoader(nil, ctxlog.TestLogger(c)).Load()
30 c.Assert(err, check.IsNil)
31 cluster, err := cfg.GetCluster("")
32 c.Assert(err, check.IsNil)
33 db := arvadostest.DB(c, cluster)
34 rows, err := db.Query(`SELECT version FROM schema_migrations`)
38 c.Assert(err, check.IsNil)
40 c.Errorf("version is in schema_migrations but not services/api/db/migrate/: %q", v)
45 c.Assert(err, check.IsNil)
47 // In the test suite, the database should be fully migrated.
48 // So, if there's anything left in todo here, there is
49 // something wrong with our "db/migrate/*.rb ==
50 // schema_migrations" reasoning.
51 c.Check(todo, check.HasLen, 0)