Restore rendering HTML tags in registered workflow panel, refs #21944
[arvados.git] / lib / boot / rails_db_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package boot
6
7 import (
8         "bytes"
9
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"
13         "gopkg.in/check.v1"
14 )
15
16 type railsDBSuite struct{}
17
18 var _ = check.Suite(&railsDBSuite{})
19
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, "")
28
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`)
35         for rows.Next() {
36                 var v string
37                 err = rows.Scan(&v)
38                 c.Assert(err, check.IsNil)
39                 if !todo[v] {
40                         c.Errorf("version is in schema_migrations but not services/api/db/migrate/: %q", v)
41                 }
42                 delete(todo, v)
43         }
44         err = rows.Close()
45         c.Assert(err, check.IsNil)
46
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)
52 }