OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package backend | 5 package backend |
6 | 6 |
7 import ( | 7 import ( |
8 "errors" | 8 "errors" |
9 "fmt" | 9 "fmt" |
10 "net/http" | 10 "net/http" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 func TestHandleStorageCleanup(t *testing.T) { | 46 func TestHandleStorageCleanup(t *testing.T) { |
47 t.Parallel() | 47 t.Parallel() |
48 | 48 |
49 Convey(`A testing setup`, t, func() { | 49 Convey(`A testing setup`, t, func() { |
50 c := gaetesting.TestingContext() | 50 c := gaetesting.TestingContext() |
51 c, tc := testclock.UseTime(c, testclock.TestTimeUTC) | 51 c, tc := testclock.UseTime(c, testclock.TestTimeUTC) |
52 | 52 |
53 st := testPurgeStorage{} | 53 st := testPurgeStorage{} |
54 b := Backend{ | 54 b := Backend{ |
55 s: coordinator.Service{ | 55 s: coordinator.Service{ |
56 » » » » StorageFunc: func(context.Context) (storage.Stor
age, error) { | 56 » » » » IntermediateStorageFunc: func(context.Context) (
storage.Storage, error) { |
57 return &st, nil | 57 return &st, nil |
58 }, | 58 }, |
59 }, | 59 }, |
60 } | 60 } |
61 | 61 |
62 tb := testBase{Context: c} | 62 tb := testBase{Context: c} |
63 r := httprouter.New() | 63 r := httprouter.New() |
64 b.InstallHandlers(r, tb.base) | 64 b.InstallHandlers(r, tb.base) |
65 | 65 |
66 s := httptest.NewServer(r) | 66 s := httptest.NewServer(r) |
(...skipping 14 matching lines...) Expand all Loading... |
81 | 81 |
82 Convey(`Will succeed, deleting the task, if invalid stream path.
`, func() { | 82 Convey(`Will succeed, deleting the task, if invalid stream path.
`, func() { |
83 resp, err := http.PostForm(fmt.Sprintf("%s/archive/clean
up", s.URL), mkValues(map[string]string{ | 83 resp, err := http.PostForm(fmt.Sprintf("%s/archive/clean
up", s.URL), mkValues(map[string]string{ |
84 "path": "!!!INVALID PATH!!!", | 84 "path": "!!!INVALID PATH!!!", |
85 })) | 85 })) |
86 So(err, ShouldBeNil) | 86 So(err, ShouldBeNil) |
87 So(resp.StatusCode, ShouldEqual, http.StatusOK) | 87 So(resp.StatusCode, ShouldEqual, http.StatusOK) |
88 }) | 88 }) |
89 | 89 |
90 Convey(`Will error if a storage instance could not be obtained.`
, func() { | 90 Convey(`Will error if a storage instance could not be obtained.`
, func() { |
91 » » » b.s.StorageFunc = func(context.Context) (storage.Storage
, error) { | 91 » » » b.s.IntermediateStorageFunc = func(context.Context) (sto
rage.Storage, error) { |
92 return nil, errors.New("test error") | 92 return nil, errors.New("test error") |
93 } | 93 } |
94 | 94 |
95 resp, err := http.PostForm(fmt.Sprintf("%s/archive/clean
up", s.URL), mkValues(map[string]string{ | 95 resp, err := http.PostForm(fmt.Sprintf("%s/archive/clean
up", s.URL), mkValues(map[string]string{ |
96 "path": "testing/+/foo", | 96 "path": "testing/+/foo", |
97 })) | 97 })) |
98 So(err, ShouldBeNil) | 98 So(err, ShouldBeNil) |
99 So(resp.StatusCode, ShouldEqual, http.StatusInternalServ
erError) | 99 So(resp.StatusCode, ShouldEqual, http.StatusInternalServ
erError) |
100 | 100 |
101 So(ds.Get(c).Get(ls), ShouldBeNil) | 101 So(ds.Get(c).Get(ls), ShouldBeNil) |
(...skipping 22 matching lines...) Expand all Loading... |
124 })) | 124 })) |
125 So(err, ShouldBeNil) | 125 So(err, ShouldBeNil) |
126 So(resp.StatusCode, ShouldEqual, http.StatusInternalServ
erError) | 126 So(resp.StatusCode, ShouldEqual, http.StatusInternalServ
erError) |
127 So(st.closed, ShouldBeTrue) | 127 So(st.closed, ShouldBeTrue) |
128 | 128 |
129 So(ds.Get(c).Get(ls), ShouldBeNil) | 129 So(ds.Get(c).Get(ls), ShouldBeNil) |
130 So(ls.State, ShouldEqual, coordinator.LSArchived) | 130 So(ls.State, ShouldEqual, coordinator.LSArchived) |
131 }) | 131 }) |
132 }) | 132 }) |
133 } | 133 } |
OLD | NEW |