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 check "gopkg.in/check.v1"
12 var _ = check.Suite(&ContainerRequestSuite{})
14 type ContainerRequestSuite struct {
18 func (s *ContainerRequestSuite) TestCRCreateWithProperties(c *check.C) {
19 s.setUpVocabulary(c, "")
23 props map[string]interface{}
26 {"Invalid prop key", map[string]interface{}{"Priority": "IDVALIMPORTANCES1"}, false},
27 {"Invalid prop value", map[string]interface{}{"IDTAGIMPORTANCES": "high"}, false},
28 {"Valid prop key & value", map[string]interface{}{"IDTAGIMPORTANCES": "IDVALIMPORTANCES1"}, true},
29 {"Empty properties", map[string]interface{}{}, true},
31 for _, tt := range tests {
32 c.Log(c.TestName()+" ", tt.name)
34 cnt, err := s.localdb.ContainerRequestCreate(s.userctx, arvados.CreateOptions{
35 Select: []string{"uuid", "properties"},
36 Attrs: map[string]interface{}{
37 "command": []string{"echo", "foo"},
38 "container_image": "arvados/apitestfixture:latest",
40 "environment": map[string]string{},
41 "mounts": map[string]interface{}{
42 "/out": map[string]interface{}{
47 "output_path": "/out",
48 "runtime_constraints": map[string]interface{}{
52 "properties": tt.props,
55 c.Assert(err, check.IsNil)
56 c.Assert(cnt.Properties, check.DeepEquals, tt.props)
58 c.Assert(err, check.NotNil)
63 func (s *ContainerRequestSuite) TestCRUpdateWithProperties(c *check.C) {
64 s.setUpVocabulary(c, "")
68 props map[string]interface{}
71 {"Invalid prop key", map[string]interface{}{"Priority": "IDVALIMPORTANCES1"}, false},
72 {"Invalid prop value", map[string]interface{}{"IDTAGIMPORTANCES": "high"}, false},
73 {"Valid prop key & value", map[string]interface{}{"IDTAGIMPORTANCES": "IDVALIMPORTANCES1"}, true},
74 {"Empty properties", map[string]interface{}{}, true},
76 for _, tt := range tests {
77 c.Log(c.TestName()+" ", tt.name)
78 cnt, err := s.localdb.ContainerRequestCreate(s.userctx, arvados.CreateOptions{
79 Attrs: map[string]interface{}{
80 "command": []string{"echo", "foo"},
81 "container_image": "arvados/apitestfixture:latest",
83 "environment": map[string]string{},
84 "mounts": map[string]interface{}{
85 "/out": map[string]interface{}{
90 "output_path": "/out",
91 "runtime_constraints": map[string]interface{}{
97 c.Assert(err, check.IsNil)
98 cnt, err = s.localdb.ContainerRequestUpdate(s.userctx, arvados.UpdateOptions{
100 Select: []string{"uuid", "properties"},
101 Attrs: map[string]interface{}{
102 "properties": tt.props,
105 c.Assert(err, check.IsNil)
106 c.Assert(cnt.Properties, check.DeepEquals, tt.props)
108 c.Assert(err, check.NotNil)