10448: Tests include enable_reuse flag and that --disable-reuse is passed to
[arvados.git] / services / datamanager / keep / keep_test.go
index 454661a723359cda9395062a4ee0743972d31cc4..ca8797ea6e403a4463cd0de27edaa139ceb5ce2c 100644 (file)
@@ -43,15 +43,15 @@ func (s *KeepSuite) TestSendTrashLists(c *C) {
        defer server.Close()
 
        tl := map[string]TrashList{
-               server.URL: TrashList{TrashRequest{"000000000000000000000000deadbeef", 99}}}
+               server.URL: {TrashRequest{"000000000000000000000000deadbeef", 99}}}
 
-       arv := arvadosclient.ArvadosClient{ApiToken: "abc123"}
-       kc := keepclient.KeepClient{Arvados: &arv, Client: &http.Client{}}
+       arv := &arvadosclient.ArvadosClient{ApiToken: "abc123"}
+       kc := keepclient.KeepClient{Arvados: arv, Client: &http.Client{}}
        kc.SetServiceRoots(map[string]string{"xxxx": server.URL},
                map[string]string{"xxxx": server.URL},
                map[string]string{})
 
-       err := SendTrashLists(&kc, tl)
+       err := SendTrashLists(nil, &kc, tl, false)
 
        c.Check(err, IsNil)
 
@@ -70,15 +70,15 @@ func (tse *TestHandlerError) ServeHTTP(writer http.ResponseWriter, req *http.Req
 
 func sendTrashListError(c *C, server *httptest.Server) {
        tl := map[string]TrashList{
-               server.URL: TrashList{TrashRequest{"000000000000000000000000deadbeef", 99}}}
+               server.URL: {TrashRequest{"000000000000000000000000deadbeef", 99}}}
 
-       arv := arvadosclient.ArvadosClient{ApiToken: "abc123"}
-       kc := keepclient.KeepClient{Arvados: &arv, Client: &http.Client{}}
+       arv := &arvadosclient.ArvadosClient{ApiToken: "abc123"}
+       kc := keepclient.KeepClient{Arvados: arv, Client: &http.Client{}}
        kc.SetServiceRoots(map[string]string{"xxxx": server.URL},
                map[string]string{"xxxx": server.URL},
                map[string]string{})
 
-       err := SendTrashLists(&kc, tl)
+       err := SendTrashLists(nil, &kc, tl, false)
 
        c.Check(err, NotNil)
        c.Check(err[0], NotNil)
@@ -101,7 +101,7 @@ type APITestData struct {
 }
 
 func (s *KeepSuite) TestGetKeepServers_UnsupportedServiceType(c *C) {
-       testGetKeepServersFromAPI(c, APITestData{1, "notadisk", 200}, "Unsupported service type")
+       testGetKeepServersFromAPI(c, APITestData{1, "notadisk", 200}, "Found no keepservices with the service type disk")
 }
 
 func (s *KeepSuite) TestGetKeepServers_ReceivedTooFewServers(c *C) {
@@ -125,21 +125,21 @@ func testGetKeepServersFromAPI(c *C, testData APITestData, expectedError string)
        }
 
        ksJSON, _ := json.Marshal(keepServers)
-       apiStubData := make(map[string]arvadostest.StatusAndBody)
-       apiStubData["/arvados/v1/keep_services"] = arvadostest.StatusAndBody{testData.statusCode, string(ksJSON)}
-       apiStub := arvadostest.APIStub{apiStubData}
+       apiStubResponses := make(map[string]arvadostest.StubResponse)
+       apiStubResponses["/arvados/v1/keep_services"] = arvadostest.StubResponse{testData.statusCode, string(ksJSON)}
+       apiStub := arvadostest.ServerStub{apiStubResponses}
 
        api := httptest.NewServer(&apiStub)
        defer api.Close()
 
-       arv := arvadosclient.ArvadosClient{
+       arv := &arvadosclient.ArvadosClient{
                Scheme:    "http",
                ApiServer: api.URL[7:],
                ApiToken:  "abc123",
                Client:    &http.Client{Transport: &http.Transport{}},
        }
 
-       kc := keepclient.KeepClient{Arvados: &arv, Client: &http.Client{}}
+       kc := keepclient.KeepClient{Arvados: arv, Client: &http.Client{}}
        kc.SetServiceRoots(map[string]string{"xxxx": "http://example.com:23456"},
                map[string]string{"xxxx": "http://example.com:23456"},
                map[string]string{})
@@ -202,10 +202,10 @@ func (s *KeepSuite) TestGetKeepServers_ReadServerResponseWithTwoBlocks(c *C) {
 }
 
 func testGetKeepServersAndSummarize(c *C, testData KeepServerTestData) {
-       ksStubData := make(map[string]arvadostest.StatusAndBody)
-       ksStubData["/status.json"] = arvadostest.StatusAndBody{testData.statusStatusCode, string(`{}`)}
-       ksStubData["/index"] = arvadostest.StatusAndBody{testData.indexStatusCode, testData.indexResponseBody}
-       ksStub := arvadostest.KeepServerStub{ksStubData}
+       ksStubResponses := make(map[string]arvadostest.StubResponse)
+       ksStubResponses["/status.json"] = arvadostest.StubResponse{testData.statusStatusCode, string(`{}`)}
+       ksStubResponses["/index"] = arvadostest.StubResponse{testData.indexStatusCode, testData.indexResponseBody}
+       ksStub := arvadostest.ServerStub{ksStubResponses}
        ks := httptest.NewServer(&ksStub)
        defer ks.Close()
 
@@ -226,21 +226,21 @@ func testGetKeepServersAndSummarize(c *C, testData KeepServerTestData) {
                }},
        }
        ksJSON, _ := json.Marshal(servers_list)
-       apiStubData := make(map[string]arvadostest.StatusAndBody)
-       apiStubData["/arvados/v1/keep_services"] = arvadostest.StatusAndBody{200, string(ksJSON)}
-       apiStub := arvadostest.APIStub{apiStubData}
+       apiStubResponses := make(map[string]arvadostest.StubResponse)
+       apiStubResponses["/arvados/v1/keep_services"] = arvadostest.StubResponse{200, string(ksJSON)}
+       apiStub := arvadostest.ServerStub{apiStubResponses}
 
        api := httptest.NewServer(&apiStub)
        defer api.Close()
 
-       arv := arvadosclient.ArvadosClient{
+       arv := &arvadosclient.ArvadosClient{
                Scheme:    "http",
                ApiServer: api.URL[7:],
                ApiToken:  "abc123",
                Client:    &http.Client{Transport: &http.Transport{}},
        }
 
-       kc := keepclient.KeepClient{Arvados: &arv, Client: &http.Client{}}
+       kc := keepclient.KeepClient{Arvados: arv, Client: &http.Client{}}
        kc.SetServiceRoots(map[string]string{"xxxx": ks.URL},
                map[string]string{"xxxx": ks.URL},
                map[string]string{})