var otherManifest = ". 68a84f561b1d1708c6baff5e019a9ab3+46+Ae5d0af96944a3690becb1decdf60cc1c937f556d@5693216f 0:46:md5sum.txt\n"
var otherPDH = "a3e8f74c6f101eae01fa08bfb4e49b3a+54"
+var fakeAuthUUID = "zzzzz-gj3su-55pqoyepgi2glem"
+var fakeAuthToken = "a3ltuwzqcu2u4sc0q7yhpc2w7s00fdcqecg5d6e0u3pfohmbjt"
+
type TestDockerClient struct {
imageLoaded string
logReader io.ReadCloser
return nil
}
+func (this *ArvTestClient) Call(method, resourceType, uuid, action string, parameters arvadosclient.Dict, output interface{}) error {
+ switch {
+ case method == "GET" && resourceType == "containers" && action == "auth":
+ return json.Unmarshal([]byte(`{
+ "kind": "arvados#api_client_authorization",
+ "uuid": "`+fakeAuthUUID+`",
+ "api_token": "`+fakeAuthToken+`"
+ }`), output)
+ default:
+ return fmt.Errorf("Not found")
+ }
+}
+
func (this *ArvTestClient) Get(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) error {
if resourceType == "collections" {
if uuid == hwPDH {
return nil
}
+func (this ArvErrorTestClient) Call(method, resourceType, uuid, action string, parameters arvadosclient.Dict, output interface{}) error {
+ return errors.New("ArvError")
+}
+
func (this ArvErrorTestClient) Get(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) error {
return errors.New("ArvError")
}
err := cr.LoadImage()
c.Check(err, IsNil)
+ err = cr.CreateContainer()
+ c.Check(err, IsNil)
+
err = cr.StartContainer()
c.Check(err, IsNil)
*cr.ExitCode = 42
cr.finalState = "Complete"
- err := cr.UpdateContainerRecordComplete()
+ err := cr.UpdateContainerRecordFinal()
c.Check(err, IsNil)
c.Check(api.Content[0]["container"].(arvadosclient.Dict)["log"], Equals, *cr.LogsPDH)
cr.Cancelled = true
cr.finalState = "Cancelled"
- err := cr.UpdateContainerRecordComplete()
+ err := cr.UpdateContainerRecordFinal()
c.Check(err, IsNil)
c.Check(api.Content[0]["container"].(arvadosclient.Dict)["log"], IsNil)
// dress rehearsal of the Run() function, starting from a JSON container record.
func FullRunHelper(c *C, record string, fn func(t *TestDockerClient)) (api *ArvTestClient, cr *ContainerRunner) {
rec := ContainerRecord{}
- err := json.NewDecoder(strings.NewReader(record)).Decode(&rec)
+ err := json.Unmarshal([]byte(record), &rec)
c.Check(err, IsNil)
docker := NewTestDockerClient()
}`
rec := ContainerRecord{}
- err := json.NewDecoder(strings.NewReader(record)).Decode(&rec)
+ err := json.Unmarshal([]byte(record), &rec)
c.Check(err, IsNil)
docker := NewTestDockerClient()
err = cr.Run()
c.Check(err, IsNil)
-
- c.Check(api.Calls, Equals, 6)
- c.Check(api.Content[5]["container"].(arvadosclient.Dict)["log"], NotNil)
-
if err != nil {
for k, v := range api.Logs {
c.Log(k)
}
}
+ c.Assert(api.Calls, Equals, 6)
+ c.Check(api.Content[5]["container"].(arvadosclient.Dict)["log"], IsNil)
c.Check(api.Content[5]["container"].(arvadosclient.Dict)["state"], Equals, "Cancelled")
-
c.Check(strings.HasSuffix(api.Logs["stdout"].String(), "foo\n"), Equals, true)
}
}
type ArvMountCmdLine struct {
- Cmd []string
+ Cmd []string
+ token string
}
-func (am *ArvMountCmdLine) ArvMountTest(c []string) (*exec.Cmd, error) {
+func (am *ArvMountCmdLine) ArvMountTest(c []string, token string) (*exec.Cmd, error) {
am.Cmd = c
+ am.token = token
return nil, nil
}
// Used by the TestStdoutWithWrongPath*()
func StdoutErrorRunHelper(c *C, record string, fn func(t *TestDockerClient)) (api *ArvTestClient, cr *ContainerRunner, err error) {
rec := ContainerRecord{}
- err = json.NewDecoder(strings.NewReader(record)).Decode(&rec)
+ err = json.Unmarshal([]byte(record), &rec)
c.Check(err, IsNil)
docker := NewTestDockerClient()