Merge lp:~fwereade/juju-core/config-2-trivial-error-message-change into lp:~juju/juju-core/trunk
- config-2-trivial-error-message-change
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | William Reade |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1271 |
Proposed branch: | lp:~fwereade/juju-core/config-2-trivial-error-message-change |
Merge into: | lp:~juju/juju-core/trunk |
Prerequisite: | lp:~fwereade/juju-core/config-1-rewrite-type |
Diff against target: |
433 lines (+101/-94) 3 files modified
charm/repo.go (+1/-1) charm/repo_test.go (+99/-92) cmd/juju/upgradecharm_test.go (+1/-1) |
To merge this branch: | bzr merge lp:~fwereade/juju-core/config-2-trivial-error-message-change |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+168576@code.launchpad.net |
Commit message
Description of the change
charm: trivial error consistency tweak
expect followup changing charm package to use errors.
William Reade (fwereade) wrote : | # |
Tim Penhey (thumper) wrote : | # |
LGTM
extra +1 if you rename curl to charmUrl :)
https:/
File charm/repo_test.go (right):
https:/
charm/repo_
It took a moment to realise that this meant charmUrl
Ian Booth (wallyworld) wrote : | # |
LGTM
https:/
File charm/repo_test.go (right):
https:/
charm/repo_
err error, curl *charm.URL) {
Rename this one too :-)
https:/
charm/repo_
+1. Please rename :-)
Maybe even charmURL
Roger Peppe (rogpeppe) wrote : | # |
looks reasonable, but what's the deal with the new errors package?
https:/
File charm/repo.go (right):
https:/
charm/repo.go:295: return &NotFoundError{
%q: %s", repoPath, curl)}
shouldn't this be using errors.NotFoundf ?
William Reade (fwereade) wrote : | # |
*** Submitted:
charm: trivial error consistency tweak
expect followup changing charm package to use errors.
R=thumper, wallyworld, rog
CC=
https:/
https:/
File charm/repo.go (right):
https:/
charm/repo.go:295: return &NotFoundError{
%q: %s", repoPath, curl)}
On 2013/06/11 12:04:55, rog wrote:
> shouldn't this be using errors.NotFoundf ?
Probably, yeah. Good catch. But it had some kinda tentacley aspects, am
preparing a new CL.
https:/
File charm/repo_test.go (right):
https:/
charm/repo_
On 2013/06/11 08:03:34, wallyworld wrote:
> +1. Please rename :-)
> Maybe even charmURL
The "curl" abbreviation is used a *lot*. I'll fix this file and try to
remember to fix other cases as I run across them.
Preview Diff
1 | === modified file 'charm/repo.go' |
2 | --- charm/repo.go 2013-05-02 15:55:42 +0000 |
3 | +++ charm/repo.go 2013-06-11 23:46:28 +0000 |
4 | @@ -292,7 +292,7 @@ |
5 | } |
6 | |
7 | func charmNotFound(curl *URL, repoPath string) error { |
8 | - return &NotFoundError{fmt.Sprintf("no charms found matching %q in %s", curl, repoPath)} |
9 | + return &NotFoundError{fmt.Sprintf("charm not found in %q: %s", repoPath, curl)} |
10 | } |
11 | |
12 | func mightBeCharm(info os.FileInfo) bool { |
13 | |
14 | === modified file 'charm/repo_test.go' |
15 | --- charm/repo_test.go 2013-05-31 02:37:23 +0000 |
16 | +++ charm/repo_test.go 2013-06-11 23:46:28 +0000 |
17 | @@ -63,18 +63,18 @@ |
18 | for _, url := range r.Form["charms"] { |
19 | cr := &charm.InfoResponse{} |
20 | response[url] = cr |
21 | - curl := charm.MustParseURL(url) |
22 | - switch curl.Name { |
23 | + charmURL := charm.MustParseURL(url) |
24 | + switch charmURL.Name { |
25 | case "borken": |
26 | cr.Errors = append(cr.Errors, "badness") |
27 | case "unwise": |
28 | cr.Warnings = append(cr.Warnings, "foolishness") |
29 | fallthrough |
30 | case "good": |
31 | - if curl.Revision == -1 { |
32 | + if charmURL.Revision == -1 { |
33 | cr.Revision = 23 |
34 | } else { |
35 | - cr.Revision = curl.Revision |
36 | + cr.Revision = charmURL.Revision |
37 | } |
38 | cr.Sha256 = s.bundleSha256 |
39 | default: |
40 | @@ -108,8 +108,8 @@ |
41 | er.Errors = []string{"entry not found"} |
42 | continue |
43 | } |
44 | - curl := charm.MustParseURL(url) |
45 | - switch curl.Name { |
46 | + charmURL := charm.MustParseURL(url) |
47 | + switch charmURL.Name { |
48 | case "borken": |
49 | er.Kind = "publish-error" |
50 | er.Errors = append(er.Errors, "badness") |
51 | @@ -137,8 +137,8 @@ |
52 | } |
53 | |
54 | func (s *MockStore) ServeCharm(w http.ResponseWriter, r *http.Request) { |
55 | - curl := charm.MustParseURL("cs:" + r.URL.Path[len("/charm/"):]) |
56 | - s.downloads = append(s.downloads, curl) |
57 | + charmURL := charm.MustParseURL("cs:" + r.URL.Path[len("/charm/"):]) |
58 | + s.downloads = append(s.downloads, charmURL) |
59 | w.Header().Set("Connection", "close") |
60 | w.Header().Set("Content-Type", "application/octet-stream") |
61 | w.Header().Set("Content-Length", strconv.Itoa(len(s.bundleBytes))) |
62 | @@ -179,31 +179,31 @@ |
63 | } |
64 | |
65 | func (s *StoreSuite) TestMissing(c *C) { |
66 | - curl := charm.MustParseURL("cs:series/missing") |
67 | + charmURL := charm.MustParseURL("cs:series/missing") |
68 | expect := `charm not found: cs:series/missing` |
69 | - _, err := s.store.Latest(curl) |
70 | + _, err := s.store.Latest(charmURL) |
71 | c.Assert(err, ErrorMatches, expect) |
72 | - _, err = s.store.Get(curl) |
73 | + _, err = s.store.Get(charmURL) |
74 | c.Assert(err, ErrorMatches, expect) |
75 | } |
76 | |
77 | func (s *StoreSuite) TestError(c *C) { |
78 | - curl := charm.MustParseURL("cs:series/borken") |
79 | + charmURL := charm.MustParseURL("cs:series/borken") |
80 | expect := `charm info errors for "cs:series/borken": badness` |
81 | - _, err := s.store.Latest(curl) |
82 | + _, err := s.store.Latest(charmURL) |
83 | c.Assert(err, ErrorMatches, expect) |
84 | - _, err = s.store.Get(curl) |
85 | + _, err = s.store.Get(charmURL) |
86 | c.Assert(err, ErrorMatches, expect) |
87 | } |
88 | |
89 | func (s *StoreSuite) TestWarning(c *C) { |
90 | - curl := charm.MustParseURL("cs:series/unwise") |
91 | + charmURL := charm.MustParseURL("cs:series/unwise") |
92 | expect := `.* WARNING juju charm: charm store reports for "cs:series/unwise": foolishness` + "\n" |
93 | - r, err := s.store.Latest(curl) |
94 | + r, err := s.store.Latest(charmURL) |
95 | c.Assert(r, Equals, 23) |
96 | c.Assert(err, IsNil) |
97 | c.Assert(c.GetTestLog(), Matches, expect) |
98 | - ch, err := s.store.Get(curl) |
99 | + ch, err := s.store.Get(charmURL) |
100 | c.Assert(ch, NotNil) |
101 | c.Assert(err, IsNil) |
102 | c.Assert(c.GetTestLog(), Matches, expect+expect) |
103 | @@ -221,9 +221,9 @@ |
104 | } |
105 | } |
106 | |
107 | -func (s *StoreSuite) assertCached(c *C, curl *charm.URL) { |
108 | +func (s *StoreSuite) assertCached(c *C, charmURL *charm.URL) { |
109 | s.server.downloads = nil |
110 | - ch, err := s.store.Get(curl) |
111 | + ch, err := s.store.Get(charmURL) |
112 | c.Assert(err, IsNil) |
113 | c.Assert(ch, NotNil) |
114 | c.Assert(s.server.downloads, IsNil) |
115 | @@ -231,76 +231,76 @@ |
116 | |
117 | func (s *StoreSuite) TestGetCacheImplicitRevision(c *C) { |
118 | base := "cs:series/good" |
119 | - curl := charm.MustParseURL(base) |
120 | - revCurl := charm.MustParseURL(base + "-23") |
121 | - ch, err := s.store.Get(curl) |
122 | + charmURL := charm.MustParseURL(base) |
123 | + revCharmURL := charm.MustParseURL(base + "-23") |
124 | + ch, err := s.store.Get(charmURL) |
125 | c.Assert(err, IsNil) |
126 | c.Assert(ch, NotNil) |
127 | - c.Assert(s.server.downloads, DeepEquals, []*charm.URL{revCurl}) |
128 | - s.assertCached(c, curl) |
129 | - s.assertCached(c, revCurl) |
130 | + c.Assert(s.server.downloads, DeepEquals, []*charm.URL{revCharmURL}) |
131 | + s.assertCached(c, charmURL) |
132 | + s.assertCached(c, revCharmURL) |
133 | } |
134 | |
135 | func (s *StoreSuite) TestGetCacheExplicitRevision(c *C) { |
136 | base := "cs:series/good-12" |
137 | - curl := charm.MustParseURL(base) |
138 | - ch, err := s.store.Get(curl) |
139 | + charmURL := charm.MustParseURL(base) |
140 | + ch, err := s.store.Get(charmURL) |
141 | c.Assert(err, IsNil) |
142 | c.Assert(ch, NotNil) |
143 | - c.Assert(s.server.downloads, DeepEquals, []*charm.URL{curl}) |
144 | - s.assertCached(c, curl) |
145 | + c.Assert(s.server.downloads, DeepEquals, []*charm.URL{charmURL}) |
146 | + s.assertCached(c, charmURL) |
147 | } |
148 | |
149 | func (s *StoreSuite) TestGetBadCache(c *C) { |
150 | c.Assert(os.Mkdir(filepath.Join(charm.CacheDir, "cache"), 0777), IsNil) |
151 | base := "cs:series/good" |
152 | - curl := charm.MustParseURL(base) |
153 | - revCurl := charm.MustParseURL(base + "-23") |
154 | - name := charm.Quote(revCurl.String()) + ".charm" |
155 | + charmURL := charm.MustParseURL(base) |
156 | + revCharmURL := charm.MustParseURL(base + "-23") |
157 | + name := charm.Quote(revCharmURL.String()) + ".charm" |
158 | err := ioutil.WriteFile(filepath.Join(charm.CacheDir, "cache", name), nil, 0666) |
159 | c.Assert(err, IsNil) |
160 | - ch, err := s.store.Get(curl) |
161 | + ch, err := s.store.Get(charmURL) |
162 | c.Assert(err, IsNil) |
163 | c.Assert(ch, NotNil) |
164 | - c.Assert(s.server.downloads, DeepEquals, []*charm.URL{revCurl}) |
165 | - s.assertCached(c, curl) |
166 | - s.assertCached(c, revCurl) |
167 | + c.Assert(s.server.downloads, DeepEquals, []*charm.URL{revCharmURL}) |
168 | + s.assertCached(c, charmURL) |
169 | + s.assertCached(c, revCharmURL) |
170 | } |
171 | |
172 | // The following tests cover the low-level CharmStore-specific API. |
173 | |
174 | func (s *StoreSuite) TestInfo(c *C) { |
175 | - curl := charm.MustParseURL("cs:series/good") |
176 | - info, err := s.store.Info(curl) |
177 | + charmURL := charm.MustParseURL("cs:series/good") |
178 | + info, err := s.store.Info(charmURL) |
179 | c.Assert(err, IsNil) |
180 | c.Assert(info.Errors, IsNil) |
181 | c.Assert(info.Revision, Equals, 23) |
182 | } |
183 | |
184 | func (s *StoreSuite) TestInfoNotFound(c *C) { |
185 | - curl := charm.MustParseURL("cs:series/missing") |
186 | - info, err := s.store.Info(curl) |
187 | + charmURL := charm.MustParseURL("cs:series/missing") |
188 | + info, err := s.store.Info(charmURL) |
189 | c.Assert(err, ErrorMatches, `charm not found: cs:series/missing`) |
190 | c.Assert(info, IsNil) |
191 | } |
192 | |
193 | func (s *StoreSuite) TestInfoError(c *C) { |
194 | - curl := charm.MustParseURL("cs:series/borken") |
195 | - info, err := s.store.Info(curl) |
196 | + charmURL := charm.MustParseURL("cs:series/borken") |
197 | + info, err := s.store.Info(charmURL) |
198 | c.Assert(err, IsNil) |
199 | c.Assert(info.Errors, DeepEquals, []string{"badness"}) |
200 | } |
201 | |
202 | func (s *StoreSuite) TestInfoWarning(c *C) { |
203 | - curl := charm.MustParseURL("cs:series/unwise") |
204 | - info, err := s.store.Info(curl) |
205 | + charmURL := charm.MustParseURL("cs:series/unwise") |
206 | + info, err := s.store.Info(charmURL) |
207 | c.Assert(err, IsNil) |
208 | c.Assert(info.Warnings, DeepEquals, []string{"foolishness"}) |
209 | } |
210 | |
211 | func (s *StoreSuite) TestEvent(c *C) { |
212 | - curl := charm.MustParseURL("cs:series/good") |
213 | - event, err := s.store.Event(curl, "") |
214 | + charmURL := charm.MustParseURL("cs:series/good") |
215 | + event, err := s.store.Event(charmURL, "") |
216 | c.Assert(err, IsNil) |
217 | c.Assert(event.Errors, IsNil) |
218 | c.Assert(event.Revision, Equals, 23) |
219 | @@ -308,8 +308,8 @@ |
220 | } |
221 | |
222 | func (s *StoreSuite) TestEventWithDigest(c *C) { |
223 | - curl := charm.MustParseURL("cs:series/good") |
224 | - event, err := s.store.Event(curl, "the-digest") |
225 | + charmURL := charm.MustParseURL("cs:series/good") |
226 | + event, err := s.store.Event(charmURL, "the-digest") |
227 | c.Assert(err, IsNil) |
228 | c.Assert(event.Errors, IsNil) |
229 | c.Assert(event.Revision, Equals, 23) |
230 | @@ -317,40 +317,40 @@ |
231 | } |
232 | |
233 | func (s *StoreSuite) TestEventNotFound(c *C) { |
234 | - curl := charm.MustParseURL("cs:series/missing") |
235 | - event, err := s.store.Event(curl, "") |
236 | + charmURL := charm.MustParseURL("cs:series/missing") |
237 | + event, err := s.store.Event(charmURL, "") |
238 | c.Assert(err, ErrorMatches, `charm event not found for "cs:series/missing"`) |
239 | c.Assert(event, IsNil) |
240 | } |
241 | |
242 | func (s *StoreSuite) TestEventNotFoundDigest(c *C) { |
243 | - curl := charm.MustParseURL("cs:series/good") |
244 | - event, err := s.store.Event(curl, "missing-digest") |
245 | + charmURL := charm.MustParseURL("cs:series/good") |
246 | + event, err := s.store.Event(charmURL, "missing-digest") |
247 | c.Assert(err, ErrorMatches, `charm event not found for "cs:series/good" with digest "missing-digest"`) |
248 | c.Assert(event, IsNil) |
249 | } |
250 | |
251 | func (s *StoreSuite) TestEventError(c *C) { |
252 | - curl := charm.MustParseURL("cs:series/borken") |
253 | - event, err := s.store.Event(curl, "") |
254 | + charmURL := charm.MustParseURL("cs:series/borken") |
255 | + event, err := s.store.Event(charmURL, "") |
256 | c.Assert(err, IsNil) |
257 | c.Assert(event.Errors, DeepEquals, []string{"badness"}) |
258 | } |
259 | |
260 | func (s *StoreSuite) TestEventWarning(c *C) { |
261 | - curl := charm.MustParseURL("cs:series/unwise") |
262 | - event, err := s.store.Event(curl, "") |
263 | + charmURL := charm.MustParseURL("cs:series/unwise") |
264 | + event, err := s.store.Event(charmURL, "") |
265 | c.Assert(err, IsNil) |
266 | c.Assert(event.Warnings, DeepEquals, []string{"foolishness"}) |
267 | } |
268 | |
269 | func (s *StoreSuite) TestBranchLocation(c *C) { |
270 | - curl := charm.MustParseURL("cs:series/name") |
271 | - location := s.store.BranchLocation(curl) |
272 | + charmURL := charm.MustParseURL("cs:series/name") |
273 | + location := s.store.BranchLocation(charmURL) |
274 | c.Assert(location, Equals, "lp:charms/series/name") |
275 | |
276 | - curl = charm.MustParseURL("cs:~user/series/name") |
277 | - location = s.store.BranchLocation(curl) |
278 | + charmURL = charm.MustParseURL("cs:~user/series/name") |
279 | + location = s.store.BranchLocation(charmURL) |
280 | c.Assert(location, Equals, "lp:~user/charms/series/name/trunk") |
281 | } |
282 | |
283 | @@ -379,12 +379,12 @@ |
284 | {"", "lp:whatever/precise/wordpress"}, |
285 | } |
286 | for _, t := range tests { |
287 | - curl, err := s.store.CharmURL(t.loc) |
288 | + charmURL, err := s.store.CharmURL(t.loc) |
289 | if t.url == "" { |
290 | c.Assert(err, ErrorMatches, fmt.Sprintf("unknown branch location: %q", t.loc)) |
291 | } else { |
292 | c.Assert(err, IsNil) |
293 | - c.Assert(curl.String(), Equals, t.url) |
294 | + c.Assert(charmURL.String(), Equals, t.url) |
295 | } |
296 | } |
297 | } |
298 | @@ -413,15 +413,22 @@ |
299 | return testing.Charms.ClonedDirPath(s.seriesPath, name) |
300 | } |
301 | |
302 | +func (s *LocalRepoSuite) checkNotFoundErr(c *C, err error, charmURL *charm.URL) { |
303 | + expect := `charm not found in "` + s.repo.Path + `": ` + charmURL.String() |
304 | + c.Check(err, ErrorMatches, expect) |
305 | +} |
306 | + |
307 | func (s *LocalRepoSuite) TestMissingCharm(c *C) { |
308 | - _, err := s.repo.Latest(charm.MustParseURL("local:series/zebra")) |
309 | - c.Assert(err, ErrorMatches, `no charms found matching "local:series/zebra" in `+s.repo.Path) |
310 | - _, err = s.repo.Get(charm.MustParseURL("local:series/zebra")) |
311 | - c.Assert(err, ErrorMatches, `no charms found matching "local:series/zebra" in `+s.repo.Path) |
312 | - _, err = s.repo.Latest(charm.MustParseURL("local:badseries/zebra")) |
313 | - c.Assert(err, ErrorMatches, `no charms found matching "local:badseries/zebra" in `+s.repo.Path) |
314 | - _, err = s.repo.Get(charm.MustParseURL("local:badseries/zebra")) |
315 | - c.Assert(err, ErrorMatches, `no charms found matching "local:badseries/zebra" in `+s.repo.Path) |
316 | + for i, str := range []string{ |
317 | + "local:series/zebra", "local:badseries/zebra", |
318 | + } { |
319 | + c.Logf("test %d: %s", i, str) |
320 | + charmURL := charm.MustParseURL(str) |
321 | + _, err := s.repo.Latest(charmURL) |
322 | + s.checkNotFoundErr(c, err, charmURL) |
323 | + _, err = s.repo.Get(charmURL) |
324 | + s.checkNotFoundErr(c, err, charmURL) |
325 | + } |
326 | } |
327 | |
328 | func (s *LocalRepoSuite) TestMissingRepo(c *C) { |
329 | @@ -438,47 +445,47 @@ |
330 | } |
331 | |
332 | func (s *LocalRepoSuite) TestMultipleVersions(c *C) { |
333 | - curl := charm.MustParseURL("local:series/upgrade") |
334 | + charmURL := charm.MustParseURL("local:series/upgrade") |
335 | s.addDir("upgrade1") |
336 | - rev, err := s.repo.Latest(curl) |
337 | + rev, err := s.repo.Latest(charmURL) |
338 | c.Assert(err, IsNil) |
339 | c.Assert(rev, Equals, 1) |
340 | - ch, err := s.repo.Get(curl) |
341 | + ch, err := s.repo.Get(charmURL) |
342 | c.Assert(err, IsNil) |
343 | c.Assert(ch.Revision(), Equals, 1) |
344 | |
345 | s.addDir("upgrade2") |
346 | - rev, err = s.repo.Latest(curl) |
347 | + rev, err = s.repo.Latest(charmURL) |
348 | c.Assert(err, IsNil) |
349 | c.Assert(rev, Equals, 2) |
350 | - ch, err = s.repo.Get(curl) |
351 | + ch, err = s.repo.Get(charmURL) |
352 | c.Assert(err, IsNil) |
353 | c.Assert(ch.Revision(), Equals, 2) |
354 | |
355 | - revCurl := curl.WithRevision(1) |
356 | - rev, err = s.repo.Latest(revCurl) |
357 | + revCharmURL := charmURL.WithRevision(1) |
358 | + rev, err = s.repo.Latest(revCharmURL) |
359 | c.Assert(err, IsNil) |
360 | c.Assert(rev, Equals, 2) |
361 | - ch, err = s.repo.Get(revCurl) |
362 | + ch, err = s.repo.Get(revCharmURL) |
363 | c.Assert(err, IsNil) |
364 | c.Assert(ch.Revision(), Equals, 1) |
365 | |
366 | - badRevCurl := curl.WithRevision(33) |
367 | - rev, err = s.repo.Latest(badRevCurl) |
368 | + badRevCharmURL := charmURL.WithRevision(33) |
369 | + rev, err = s.repo.Latest(badRevCharmURL) |
370 | c.Assert(err, IsNil) |
371 | c.Assert(rev, Equals, 2) |
372 | - ch, err = s.repo.Get(badRevCurl) |
373 | - c.Assert(err, ErrorMatches, `no charms found matching "local:series/upgrade-33" in `+s.repo.Path) |
374 | + _, err = s.repo.Get(badRevCharmURL) |
375 | + s.checkNotFoundErr(c, err, badRevCharmURL) |
376 | } |
377 | |
378 | func (s *LocalRepoSuite) TestBundle(c *C) { |
379 | - curl := charm.MustParseURL("local:series/dummy") |
380 | + charmURL := charm.MustParseURL("local:series/dummy") |
381 | s.addBundle("dummy") |
382 | |
383 | - rev, err := s.repo.Latest(curl) |
384 | + rev, err := s.repo.Latest(charmURL) |
385 | c.Assert(err, IsNil) |
386 | c.Assert(rev, Equals, 1) |
387 | - ch, err := s.repo.Get(curl) |
388 | + ch, err := s.repo.Get(charmURL) |
389 | c.Assert(err, IsNil) |
390 | c.Assert(ch.Revision(), Equals, 1) |
391 | } |
392 | @@ -493,9 +500,9 @@ |
393 | err = ioutil.WriteFile(filepath.Join(samplePath, "metadata.yaml"), gibberish, 0666) |
394 | c.Assert(err, IsNil) |
395 | |
396 | - curl := charm.MustParseURL("local:series/dummy") |
397 | + charmURL := charm.MustParseURL("local:series/dummy") |
398 | s.addDir("dummy") |
399 | - ch, err := s.repo.Get(curl) |
400 | + ch, err := s.repo.Get(charmURL) |
401 | c.Assert(err, IsNil) |
402 | c.Assert(ch.Revision(), Equals, 1) |
403 | c.Assert(c.GetTestLog(), Matches, ` |
404 | @@ -516,11 +523,11 @@ |
405 | c.Assert(err, IsNil) |
406 | renameSibling(c, s.addDir("dummy"), ".dummy") |
407 | renameSibling(c, s.addBundle("dummy"), "dummy.notacharm") |
408 | - curl := charm.MustParseURL("local:series/dummy") |
409 | + charmURL := charm.MustParseURL("local:series/dummy") |
410 | |
411 | - _, err = s.repo.Get(curl) |
412 | - c.Assert(err, ErrorMatches, `no charms found matching "local:series/dummy" in `+s.repo.Path) |
413 | - _, err = s.repo.Latest(curl) |
414 | - c.Assert(err, ErrorMatches, `no charms found matching "local:series/dummy" in `+s.repo.Path) |
415 | + _, err = s.repo.Get(charmURL) |
416 | + s.checkNotFoundErr(c, err, charmURL) |
417 | + _, err = s.repo.Latest(charmURL) |
418 | + s.checkNotFoundErr(c, err, charmURL) |
419 | c.Assert(c.GetTestLog(), Equals, "") |
420 | } |
421 | |
422 | === modified file 'cmd/juju/upgradecharm_test.go' |
423 | --- cmd/juju/upgradecharm_test.go 2013-05-16 15:37:05 +0000 |
424 | +++ cmd/juju/upgradecharm_test.go 2013-06-11 23:46:28 +0000 |
425 | @@ -46,7 +46,7 @@ |
426 | // overwrites it (TearDownTest will revert it again). |
427 | os.Setenv("JUJU_REPOSITORY", "") |
428 | err = runUpgradeCharm(c, "riak", "--repository=") |
429 | - c.Assert(err, ErrorMatches, `no charms found matching "local:precise/riak" in .*`) |
430 | + c.Assert(err, ErrorMatches, `charm not found in ".*": local:precise/riak`) |
431 | } |
432 | |
433 | func (s *UpgradeCharmErrorsSuite) TestInvalidService(c *C) { |
Reviewers: mp+168576_ code.launchpad. net,
Message:
Please take a look.
Description:
charm: trivial error consistency tweak
https:/ /code.launchpad .net/~fwereade/ juju-core/ config- 2-trivial- error-message- change/ +merge/ 168576
Requires: /code.launchpad .net/~fwereade/ juju-core/ config- 1-rewrite- type/+merge/ 168575
https:/
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/10178043/
Affected files: upgradecharm_ test.go
A [revision details]
M charm/repo.go
M charm/repo_test.go
M cmd/juju/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: charm/repo.go
=== modified file 'charm/repo.go'
--- charm/repo.go 2013-05-02 15:55:42 +0000
+++ charm/repo.go 2013-06-10 20:50:42 +0000
@@ -292,7 +292,7 @@
}
func charmNotFound(curl *URL, repoPath string) error { fmt.Sprintf( "no charms found matching %q in %s", fmt.Sprintf( "charm not found in %q: %s", repoPath,
- return &NotFoundError{
curl, repoPath)}
+ return &NotFoundError{
curl)}
}
func mightBeCharm(info os.FileInfo) bool {
Index: charm/repo_test.go repo_test. go' Charms. ClonedDirPath( s.seriesPath, name)
=== modified file 'charm/
--- charm/repo_test.go 2013-05-31 02:37:23 +0000
+++ charm/repo_test.go 2013-06-10 20:50:42 +0000
@@ -413,15 +413,22 @@
return testing.
}
+func (s *LocalRepoSuite) checkNotFoundErr(c *C, err error, curl Latest( charm.MustParse URL("local: series/ zebra") ) series/ zebra" in `+s.repo.Path) Get(charm. MustParseURL( "local: series/ zebra") ) series/ zebra" in `+s.repo.Path) Latest( charm.MustParse URL("local: badseries/ zebra") ) badseries/ zebra" in `+s.repo.Path) Get(charm. MustParseURL( "local: badseries/ zebra") ) badseries/ zebra" in `+s.repo.Path) series/ zebra", "local: badseries/ zebra", URL(str) Err(c, err, curl) Err(c, err, curl)
*charm.URL) {
+ expect := `charm not found in "` + s.repo.Path + `": ` + curl.String()
+ c.Check(err, ErrorMatches, expect)
+}
+
func (s *LocalRepoSuite) TestMissingCharm(c *C) {
- _, err := s.repo.
- c.Assert(err, ErrorMatches, `no charms found
matching "local:
- _, err = s.repo.
- c.Assert(err, ErrorMatches, `no charms found
matching "local:
- _, err = s.repo.
- c.Assert(err, ErrorMatches, `no charms found
matching "local:
- _, err = s.repo.
- c.Assert(err, ErrorMatches, `no charms found
matching "local:
+ for i, str := range []string{
+ "local:
+ } {
+ c.Logf("test %d: %s", i, str)
+ curl := charm.MustParse
+ _, err := s.repo.Latest(curl)
+ s.checkNotFound
+ _, err = s.repo.Get(curl)
+ s.checkNotFound
+ }
}
func (s *LocalRepoSuite) TestMissingRepo(c *C) { Latest( badRevCurl) Get(badRevCurl) series/ upgrade- 33" in `+s.repo.Path) Get(badRevCurl) Err(c, err, badRevCurl)
@@ -467,8 +474,8 @@
rev, err = s.repo.
c.Assert(err, IsNil)
c.Assert(rev, Equals, 2)
- ch, err = s.repo.
- c.Assert(err, ErrorMatches, `no charms found
matching "local:
+ _, err = s.repo.
+ s.checkNotFound
}
func (s *LocalRepoSuite) TestBundle(c *C) ...