1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
8 "git.arvados.org/arvados.git/sdk/go/arvados"
9 "git.arvados.org/arvados.git/sdk/go/arvadostest"
10 check "gopkg.in/check.v1"
13 var _ = check.Suite(&LinkSuite{})
15 type LinkSuite struct {
19 func (s *LinkSuite) TestLinkCreateWithProperties(c *check.C) {
20 s.setUpVocabulary(c, "")
24 props map[string]interface{}
27 {"Invalid prop key", map[string]interface{}{"Priority": "IDVALIMPORTANCES1"}, false},
28 {"Invalid prop value", map[string]interface{}{"IDTAGIMPORTANCES": "high"}, false},
29 {"Valid prop key & value", map[string]interface{}{"IDTAGIMPORTANCES": "IDVALIMPORTANCES1"}, true},
30 {"Empty properties", map[string]interface{}{}, true},
32 for _, tt := range tests {
33 c.Log(c.TestName()+" ", tt.name)
35 lnk, err := s.localdb.LinkCreate(s.userctx, arvados.CreateOptions{
36 Select: []string{"uuid", "properties"},
37 Attrs: map[string]interface{}{
39 "tail_uuid": "zzzzz-j7d0g-publicfavorites",
40 "head_uuid": arvadostest.FooCollection,
41 "properties": tt.props,
44 c.Assert(err, check.IsNil)
45 c.Assert(lnk.Properties, check.DeepEquals, tt.props)
47 c.Assert(err, check.NotNil)
52 func (s *LinkSuite) TestLinkUpdateWithProperties(c *check.C) {
53 s.setUpVocabulary(c, "")
57 props map[string]interface{}
60 {"Invalid prop key", map[string]interface{}{"Priority": "IDVALIMPORTANCES1"}, false},
61 {"Invalid prop value", map[string]interface{}{"IDTAGIMPORTANCES": "high"}, false},
62 {"Valid prop key & value", map[string]interface{}{"IDTAGIMPORTANCES": "IDVALIMPORTANCES1"}, true},
63 {"Empty properties", map[string]interface{}{}, true},
65 for _, tt := range tests {
66 c.Log(c.TestName()+" ", tt.name)
67 lnk, err := s.localdb.LinkCreate(s.userctx, arvados.CreateOptions{
68 Attrs: map[string]interface{}{
70 "tail_uuid": "zzzzz-j7d0g-publicfavorites",
71 "head_uuid": arvadostest.FooCollection,
74 c.Assert(err, check.IsNil)
75 lnk, err = s.localdb.LinkUpdate(s.userctx, arvados.UpdateOptions{
77 Select: []string{"uuid", "properties"},
78 Attrs: map[string]interface{}{
79 "properties": tt.props,
82 c.Assert(err, check.IsNil)
83 c.Assert(lnk.Properties, check.DeepEquals, tt.props)
85 c.Assert(err, check.NotNil)