X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9997ada67ce36d2fbe831bce473aa61250727aff..16c01c88acf2a11d2e764278dcb1fb9aaa582559:/services/ws/session_v0_test.go diff --git a/services/ws/session_v0_test.go b/services/ws/session_v0_test.go index 9f743e0b5e..bd70b44459 100644 --- a/services/ws/session_v0_test.go +++ b/services/ws/session_v0_test.go @@ -14,9 +14,9 @@ import ( "sync" "time" - "git.curoverse.com/arvados.git/sdk/go/arvados" - "git.curoverse.com/arvados.git/sdk/go/arvadostest" - "git.curoverse.com/arvados.git/sdk/go/ctxlog" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvadostest" + "git.arvados.org/arvados.git/sdk/go/ctxlog" "golang.org/x/net/websocket" check "gopkg.in/check.v1" ) @@ -71,15 +71,28 @@ func (s *v0Suite) TestFilters(c *check.C) { conn, r, w := s.testClient() defer conn.Close() - c.Check(w.Encode(map[string]interface{}{ - "method": "subscribe", - "filters": [][]interface{}{{"event_type", "in", []string{"update"}}}, - }), check.IsNil) - s.expectStatus(c, r, 200) + cmd := func(method, eventType string, status int) { + c.Check(w.Encode(map[string]interface{}{ + "method": method, + "filters": [][]interface{}{{"event_type", "in", []string{eventType}}}, + }), check.IsNil) + s.expectStatus(c, r, status) + } + cmd("subscribe", "update", 200) + cmd("subscribe", "update", 200) + cmd("subscribe", "create", 200) + cmd("subscribe", "update", 200) + cmd("unsubscribe", "blip", 400) + cmd("unsubscribe", "create", 200) + cmd("unsubscribe", "update", 200) go s.emitEvents(nil) lg := s.expectLog(c, r) c.Check(lg.EventType, check.Equals, "update") + + cmd("unsubscribe", "update", 200) + cmd("unsubscribe", "update", 200) + cmd("unsubscribe", "update", 400) } func (s *v0Suite) TestLastLogID(c *check.C) { @@ -195,8 +208,8 @@ func (s *v0Suite) TestTrashedCollection(c *check.C) { ac := arvados.NewClientFromEnv() ac.AuthToken = s.token - coll := &arvados.Collection{ManifestText: ""} - err := ac.RequestAndDecode(coll, "POST", "arvados/v1/collections", s.jsonBody("collection", coll), map[string]interface{}{"ensure_unique_name": true}) + var coll arvados.Collection + err := ac.RequestAndDecode(&coll, "POST", "arvados/v1/collections", s.jsonBody("collection", `{"manifest_text":""}`), map[string]interface{}{"ensure_unique_name": true}) c.Assert(err, check.IsNil) s.ignoreLogID = s.lastLogID(c) @@ -277,7 +290,7 @@ func (s *v0Suite) emitEvents(uuidChan chan<- string) { wf := &arvados.Workflow{ Name: "ws_test", } - err := ac.RequestAndDecode(wf, "POST", "arvados/v1/workflows", s.jsonBody("workflow", wf), map[string]interface{}{"ensure_unique_name": true}) + err := ac.RequestAndDecode(wf, "POST", "arvados/v1/workflows", s.jsonBody("workflow", `{"name":"ws_test"}`), map[string]interface{}{"ensure_unique_name": true}) if err != nil { panic(err) } @@ -285,17 +298,17 @@ func (s *v0Suite) emitEvents(uuidChan chan<- string) { uuidChan <- wf.UUID } lg := &arvados.Log{} - err = ac.RequestAndDecode(lg, "POST", "arvados/v1/logs", s.jsonBody("log", &arvados.Log{ - ObjectUUID: wf.UUID, - EventType: "blip", - Properties: map[string]interface{}{ + err = ac.RequestAndDecode(lg, "POST", "arvados/v1/logs", s.jsonBody("log", map[string]interface{}{ + "object_uuid": wf.UUID, + "event_type": "blip", + "properties": map[string]interface{}{ "beep": "boop", }, }), nil) if err != nil { panic(err) } - err = ac.RequestAndDecode(wf, "PUT", "arvados/v1/workflows/"+wf.UUID, s.jsonBody("workflow", wf), nil) + err = ac.RequestAndDecode(wf, "PUT", "arvados/v1/workflows/"+wf.UUID, s.jsonBody("workflow", `{"name":"ws_test"}`), nil) if err != nil { panic(err) } @@ -303,12 +316,16 @@ func (s *v0Suite) emitEvents(uuidChan chan<- string) { } func (s *v0Suite) jsonBody(rscName string, ob interface{}) io.Reader { - j, err := json.Marshal(ob) - if err != nil { - panic(err) + val, ok := ob.(string) + if !ok { + j, err := json.Marshal(ob) + if err != nil { + panic(err) + } + val = string(j) } v := url.Values{} - v[rscName] = []string{string(j)} + v[rscName] = []string{val} return bytes.NewBufferString(v.Encode()) }