18600: De-duplicate test code.
authorTom Clegg <tom@curii.com>
Thu, 3 Mar 2022 21:19:19 +0000 (16:19 -0500)
committerTom Clegg <tom@curii.com>
Thu, 3 Mar 2022 21:19:19 +0000 (16:19 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/controller/localdb/collection_test.go

index bbfb811165c7c869cfc62e6306611d9e60c6f457..efcc830f1e58b8e54c4933e19209357f7ac0b8f1 100644 (file)
@@ -71,7 +71,7 @@ func (s *CollectionSuite) setUpVocabulary(c *check.C, testVocabulary string) {
        s.localdb.vocabularyCache = voc
 }
 
-func (s *CollectionSuite) TestCollectionCreateWithProperties(c *check.C) {
+func (s *CollectionSuite) TestCollectionCreateAndUpdateWithProperties(c *check.C) {
        s.setUpVocabulary(c, "")
        ctx := auth.NewContext(context.Background(), &auth.Credentials{Tokens: []string{arvadostest.ActiveTokenV2}})
 
@@ -88,6 +88,7 @@ func (s *CollectionSuite) TestCollectionCreateWithProperties(c *check.C) {
        for _, tt := range tests {
                c.Log(c.TestName()+" ", tt.name)
 
+               // Create with properties
                coll, err := s.localdb.CollectionCreate(ctx, arvados.CreateOptions{
                        Select: []string{"uuid", "properties"},
                        Attrs: map[string]interface{}{
@@ -99,26 +100,9 @@ func (s *CollectionSuite) TestCollectionCreateWithProperties(c *check.C) {
                } else {
                        c.Assert(err, check.NotNil)
                }
-       }
-}
-
-func (s *CollectionSuite) TestCollectionUpdateWithProperties(c *check.C) {
-       s.setUpVocabulary(c, "")
-       ctx := auth.NewContext(context.Background(), &auth.Credentials{Tokens: []string{arvadostest.ActiveTokenV2}})
 
-       tests := []struct {
-               name    string
-               props   map[string]interface{}
-               success bool
-       }{
-               {"Invalid prop key", map[string]interface{}{"Priority": "IDVALIMPORTANCES1"}, false},
-               {"Invalid prop value", map[string]interface{}{"IDTAGIMPORTANCES": "high"}, false},
-               {"Valid prop key & value", map[string]interface{}{"IDTAGIMPORTANCES": "IDVALIMPORTANCES1"}, true},
-               {"Empty properties", map[string]interface{}{}, true},
-       }
-       for _, tt := range tests {
-               c.Log(c.TestName()+" ", tt.name)
-               coll, err := s.localdb.CollectionCreate(ctx, arvados.CreateOptions{})
+               // Create, then update with properties
+               coll, err = s.localdb.CollectionCreate(ctx, arvados.CreateOptions{})
                c.Assert(err, check.IsNil)
                coll, err = s.localdb.CollectionUpdate(ctx, arvados.UpdateOptions{
                        UUID:   coll.UUID,