5 "git.curoverse.com/arvados.git/sdk/go/arvadostest"
11 // Gocheck boilerplate
12 func Test(t *testing.T) {
16 var _ = Suite(&ServerRequiredSuite{})
18 // Tests that require the Keep server running
19 type ServerRequiredSuite struct{}
21 func (s *ServerRequiredSuite) SetUpSuite(c *C) {
22 arvadostest.StartAPI()
23 arvadostest.StartKeep()
26 func (s *ServerRequiredSuite) SetUpTest(c *C) {
27 arvadostest.ResetEnv()
30 func (s *ServerRequiredSuite) TestMakeArvadosClientSecure(c *C) {
31 os.Setenv("ARVADOS_API_HOST_INSECURE", "")
32 kc, err := MakeArvadosClient()
33 c.Assert(err, Equals, nil)
34 c.Check(kc.ApiServer, Equals, os.Getenv("ARVADOS_API_HOST"))
35 c.Check(kc.ApiToken, Equals, os.Getenv("ARVADOS_API_TOKEN"))
36 c.Check(kc.ApiInsecure, Equals, false)
39 func (s *ServerRequiredSuite) TestMakeArvadosClientInsecure(c *C) {
40 os.Setenv("ARVADOS_API_HOST_INSECURE", "true")
41 kc, err := MakeArvadosClient()
42 c.Assert(err, Equals, nil)
43 c.Check(kc.ApiInsecure, Equals, true)
44 c.Check(kc.ApiServer, Equals, os.Getenv("ARVADOS_API_HOST"))
45 c.Check(kc.ApiToken, Equals, os.Getenv("ARVADOS_API_TOKEN"))
46 c.Check(kc.Client.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify, Equals, true)
49 func (s *ServerRequiredSuite) TestCreatePipelineTemplate(c *C) {
50 arv, err := MakeArvadosClient()
53 err = arv.Create("pipeline_templates",
54 Dict{"pipeline_template": Dict{
57 "c1": map[string]string{"script": "script1"},
58 "c2": map[string]string{"script": "script2"}}}},
60 c.Assert(err, Equals, nil)
61 c.Assert(getback["name"], Equals, "tmp")
62 c.Assert(getback["components"].(map[string]interface{})["c2"].(map[string]interface{})["script"], Equals, "script2")
64 uuid := getback["uuid"].(string)
66 err = arv.Update("pipeline_templates", uuid,
68 "pipeline_template": Dict{"name": "tmp2"}},
70 c.Assert(err, Equals, nil)
71 c.Assert(getback["name"], Equals, "tmp2")
73 c.Assert(getback["uuid"].(string), Equals, uuid)
75 err = arv.Delete("pipeline_templates", uuid, nil, &getback)
76 c.Assert(err, Equals, nil)
77 c.Assert(getback["name"], Equals, "tmp2")
80 func (s *ServerRequiredSuite) TestErrorResponse(c *C) {
81 arv, _ := MakeArvadosClient()
86 err := arv.Create("logs",
87 Dict{"log": Dict{"bogus_attr": "foo"}},
89 c.Assert(err, ErrorMatches, ".*unknown attribute: bogus_attr.*")
90 c.Assert(err, FitsTypeOf, ArvadosApiError{})
91 c.Assert(err.(ArvadosApiError).HttpStatusCode, Equals, 422)
95 err := arv.Create("bogus",
96 Dict{"bogus": Dict{}},
98 c.Assert(err, ErrorMatches, "Path not found")
99 c.Assert(err, FitsTypeOf, ArvadosApiError{})
100 c.Assert(err.(ArvadosApiError).HttpStatusCode, Equals, 404)