20183: Deduplicate test suite setup.
[arvados.git] / lib / controller / localdb / container_request_test.go
index 2d89f58ab5325b96993155b0e24f1e6e48085e98..45b6de453b160aacc441a0f978e69e549c0f478a 100644 (file)
@@ -7,66 +7,16 @@ package localdb
 import (
        "context"
 
-       "git.arvados.org/arvados.git/lib/config"
-       "git.arvados.org/arvados.git/lib/controller/rpc"
-       "git.arvados.org/arvados.git/lib/ctrlctx"
        "git.arvados.org/arvados.git/sdk/go/arvados"
        "git.arvados.org/arvados.git/sdk/go/arvadostest"
        "git.arvados.org/arvados.git/sdk/go/auth"
-       "git.arvados.org/arvados.git/sdk/go/ctxlog"
        check "gopkg.in/check.v1"
 )
 
 var _ = check.Suite(&ContainerRequestSuite{})
 
 type ContainerRequestSuite struct {
-       cluster  *arvados.Cluster
-       localdb  *Conn
-       railsSpy *arvadostest.Proxy
-}
-
-func (s *ContainerRequestSuite) TearDownSuite(c *check.C) {
-       // Undo any changes/additions to the user database so they
-       // don't affect subsequent tests.
-       arvadostest.ResetEnv()
-       c.Check(arvados.NewClientFromEnv().RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
-}
-
-func (s *ContainerRequestSuite) SetUpTest(c *check.C) {
-       cfg, err := config.NewLoader(nil, ctxlog.TestLogger(c)).Load()
-       c.Assert(err, check.IsNil)
-       s.cluster, err = cfg.GetCluster("")
-       c.Assert(err, check.IsNil)
-       s.localdb = NewConn(context.Background(), s.cluster, (&ctrlctx.DBConnector{PostgreSQL: s.cluster.PostgreSQL}).GetDB)
-       s.railsSpy = arvadostest.NewProxy(c, s.cluster.Services.RailsAPI)
-       *s.localdb.railsProxy = *rpc.NewConn(s.cluster.ClusterID, s.railsSpy.URL, true, rpc.PassthroughTokenProvider)
-}
-
-func (s *ContainerRequestSuite) TearDownTest(c *check.C) {
-       s.railsSpy.Close()
-}
-
-func (s *ContainerRequestSuite) setUpVocabulary(c *check.C, testVocabulary string) {
-       if testVocabulary == "" {
-               testVocabulary = `{
-                       "strict_tags": false,
-                       "tags": {
-                               "IDTAGIMPORTANCES": {
-                                       "strict": true,
-                                       "labels": [{"label": "Importance"}, {"label": "Priority"}],
-                                       "values": {
-                                               "IDVALIMPORTANCES1": { "labels": [{"label": "Critical"}, {"label": "Urgent"}, {"label": "High"}] },
-                                               "IDVALIMPORTANCES2": { "labels": [{"label": "Normal"}, {"label": "Moderate"}] },
-                                               "IDVALIMPORTANCES3": { "labels": [{"label": "Low"}] }
-                                       }
-                               }
-                       }
-               }`
-       }
-       voc, err := arvados.NewVocabulary([]byte(testVocabulary), []string{})
-       c.Assert(err, check.IsNil)
-       s.localdb.vocabularyCache = voc
-       s.cluster.API.VocabularyPath = "foo"
+       localdbSuite
 }
 
 func (s *ContainerRequestSuite) TestCRCreateWithProperties(c *check.C) {