Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(483)

Side by Side Diff: store/lpad_test.go

Issue 5704056: store: add PublishCharmsDistro function
Patch Set: store: add PublishCharmsDistro function Created 12 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « store/lpad.go ('k') | store/store_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 package store_test
2
3 import (
4 "fmt"
5 . "launchpad.net/gocheck"
6 "launchpad.net/juju/go/charm"
7 "launchpad.net/juju/go/store"
8 "launchpad.net/lpad"
9 )
10
11 var apiBase = lpad.APIBase(testServer.URL)
12
13 var jsonType = map[string]string{
14 "Content-Type": "application/json",
15 }
16
17 func (s *StoreSuite) TestPublishCharmDistro(c *C) {
18 branch := s.dummyBranch(c, "~joe/charms/oneiric/dummy/trunk")
19
20 // The Distro call will look for bare /charms, first.
21 testServer.Response(200, jsonType, "{}")
22
23 // And then it picks up the tips.
24 data := fmt.Sprintf(`[`+
25 `["file://%s", "rev1", ["oneiric", "precise"]],`+
26 `["file://%s", "%s", []],`+
27 `["file:///non-existent/~jeff/charms/precise/bad/trunk", "rev2", []],`+
28 `["file:///non-existent/~jeff/charms/precise/bad/skip-me", "rev3 ", []]`+
29 `]`,
30 branch.path(), branch.path(), branch.digest())
31 testServer.Response(200, jsonType, data)
32
33 err := store.PublishCharmsDistro(s.store, apiBase)
34
35 // Should have a single failure from the trunk branch that doesn't
36 // exist. The redundant update with the known digest should be
37 // ignored, and skip-me isn't a supported branch name so it's
38 // ignored as well.
39 c.Assert(err, ErrorMatches, `1 branch\(es\) failed to be published`)
40 berr := err.(store.PublishBranchErrors)[0]
41 c.Assert(berr.URL, Equals, "file:///non-existent/~jeff/charms/precise/ba d/trunk")
42 c.Assert(berr.Err, ErrorMatches, "(?s).*bzr: ERROR: Not a branch.*")
43
44 for _, url := range []string{"cs:oneiric/dummy", "cs:precise/dummy-0", " cs:~joe/oneiric/dummy-0"} {
45 dummy, err := s.store.CharmInfo(charm.MustParseURL(url))
46 c.Assert(err, IsNil)
47 c.Assert(dummy.Meta().Name, Equals, "dummy")
48 }
49
50 // The known digest should have been ignored, so revision is still at 0.
51 _, err = s.store.CharmInfo(charm.MustParseURL("cs:~joe/oneiric/dummy-1") )
52 c.Assert(err, Equals, store.ErrNotFound)
53
54 // bare /charms lookup
55 req := testServer.WaitRequest()
56 c.Assert(req.Method, Equals, "GET")
57 c.Assert(req.URL.Path, Equals, "/charms")
58
59 // tips request
60 req = testServer.WaitRequest()
61 c.Assert(req.Method, Equals, "GET")
62 c.Assert(req.URL.Path, Equals, "/charms")
63 c.Assert(req.Form["ws.op"], DeepEquals, []string{"getBranchTips"})
64 c.Assert(req.Form["since"], IsNil)
65
66 // Request must be signed by juju.
67 c.Assert(req.Header.Get("Authorization"), Matches, `.*oauth_consumer_key ="juju".*`)
68 }
OLDNEW
« no previous file with comments | « store/lpad.go ('k') | store/store_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b