+// Ensure MountUUID in a pull list is correctly translated to a Volume
+// argument passed to writePulledBlock().
+func (s *PullWorkerTestSuite) TestSpecifyMountUUID(c *C) {
+ defer func(f func(Volume, []byte, string)) {
+ writePulledBlock = f
+ }(writePulledBlock)
+
+ for _, spec := range []struct {
+ sendUUID string
+ expectVolume Volume
+ }{
+ {
+ sendUUID: "",
+ expectVolume: nil,
+ },
+ {
+ sendUUID: KeepVM.Mounts()[0].UUID,
+ expectVolume: KeepVM.Mounts()[0].volume,
+ },
+ } {
+ writePulledBlock = func(v Volume, _ []byte, _ string) {
+ c.Check(v, Equals, spec.expectVolume)
+ }
+
+ resp := IssueRequest(&RequestTester{
+ uri: "/pull",
+ apiToken: theConfig.systemAuthToken,
+ method: "PUT",
+ requestBody: []byte(`[{
+ "locator":"acbd18db4cc2f85cedef654fccc4a4d8+3",
+ "servers":["server_1","server_2"],
+ "mountuuid":"` + spec.sendUUID + `"}]`),
+ })
+ c.Assert(resp.Code, Equals, http.StatusOK)
+ expectEqualWithin(c, time.Second, 0, func() interface{} {
+ st := pullq.Status()
+ return st.InProgress + st.Queued
+ })
+ }
+}