1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
10 "git.arvados.org/arvados.git/sdk/go/arvados"
11 "git.arvados.org/arvados.git/sdk/go/arvadostest"
12 "git.arvados.org/arvados.git/sdk/go/auth"
13 check "gopkg.in/check.v1"
16 var _ = check.Suite(&ContainerRequestSuite{})
18 type ContainerRequestSuite struct {
22 func (s *ContainerRequestSuite) TestCRCreateWithProperties(c *check.C) {
23 s.setUpVocabulary(c, "")
24 ctx := auth.NewContext(context.Background(), &auth.Credentials{Tokens: []string{arvadostest.ActiveTokenV2}})
28 props map[string]interface{}
31 {"Invalid prop key", map[string]interface{}{"Priority": "IDVALIMPORTANCES1"}, false},
32 {"Invalid prop value", map[string]interface{}{"IDTAGIMPORTANCES": "high"}, false},
33 {"Valid prop key & value", map[string]interface{}{"IDTAGIMPORTANCES": "IDVALIMPORTANCES1"}, true},
34 {"Empty properties", map[string]interface{}{}, true},
36 for _, tt := range tests {
37 c.Log(c.TestName()+" ", tt.name)
39 cnt, err := s.localdb.ContainerRequestCreate(ctx, arvados.CreateOptions{
40 Select: []string{"uuid", "properties"},
41 Attrs: map[string]interface{}{
42 "command": []string{"echo", "foo"},
43 "container_image": "arvados/apitestfixture:latest",
45 "environment": map[string]string{},
46 "mounts": map[string]interface{}{
47 "/out": map[string]interface{}{
52 "output_path": "/out",
53 "runtime_constraints": map[string]interface{}{
57 "properties": tt.props,
60 c.Assert(err, check.IsNil)
61 c.Assert(cnt.Properties, check.DeepEquals, tt.props)
63 c.Assert(err, check.NotNil)
68 func (s *ContainerRequestSuite) TestCRUpdateWithProperties(c *check.C) {
69 s.setUpVocabulary(c, "")
70 ctx := auth.NewContext(context.Background(), &auth.Credentials{Tokens: []string{arvadostest.ActiveTokenV2}})
74 props map[string]interface{}
77 {"Invalid prop key", map[string]interface{}{"Priority": "IDVALIMPORTANCES1"}, false},
78 {"Invalid prop value", map[string]interface{}{"IDTAGIMPORTANCES": "high"}, false},
79 {"Valid prop key & value", map[string]interface{}{"IDTAGIMPORTANCES": "IDVALIMPORTANCES1"}, true},
80 {"Empty properties", map[string]interface{}{}, true},
82 for _, tt := range tests {
83 c.Log(c.TestName()+" ", tt.name)
84 cnt, err := s.localdb.ContainerRequestCreate(ctx, arvados.CreateOptions{
85 Attrs: map[string]interface{}{
86 "command": []string{"echo", "foo"},
87 "container_image": "arvados/apitestfixture:latest",
89 "environment": map[string]string{},
90 "mounts": map[string]interface{}{
91 "/out": map[string]interface{}{
96 "output_path": "/out",
97 "runtime_constraints": map[string]interface{}{
103 c.Assert(err, check.IsNil)
104 cnt, err = s.localdb.ContainerRequestUpdate(ctx, arvados.UpdateOptions{
106 Select: []string{"uuid", "properties"},
107 Attrs: map[string]interface{}{
108 "properties": tt.props,
111 c.Assert(err, check.IsNil)
112 c.Assert(cnt.Properties, check.DeepEquals, tt.props)
114 c.Assert(err, check.NotNil)