~dave-cheney/pyjuju/go-environment-watcher

« back to all changes in this revision

Viewing changes to store/store_test.go

  • Committer: William Reade
  • Author(s): William Reade
  • Date: 2012-04-27 15:08:25 UTC
  • mfrom: (92.2.9 master)
  • Revision ID: fwereade@gmail.com-20120427150825-hmr8ug6y1ybu5fgm
Make test charm repository available from testing package

charm, state, and store were all testing against the same repo, and very
soon so will hook (so it can have a real unit to work with); seemed sensible
to make it hard for tests to accidentally write to charms they shouldn't,
and to avoid explicit use of "../charm/testrepo" in other packages.

Only notable change is file mode testing; it was actually only tested in one
place, and implicitly at that, so it's now explicitly tested in its own
test.

R=niemeyer, rog
CC=
https://codereview.appspot.com/5845051

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
        "launchpad.net/juju/go/charm"
9
9
        "launchpad.net/juju/go/log"
10
10
        "launchpad.net/juju/go/store"
 
11
        "launchpad.net/juju/go/testing"
11
12
        "launchpad.net/mgo/bson"
12
 
        "path/filepath"
13
13
        "strconv"
14
 
        "testing"
 
14
        stdtesting "testing"
15
15
        "time"
16
16
)
17
17
 
18
 
func Test(t *testing.T) {
 
18
func Test(t *stdtesting.T) {
19
19
        TestingT(t)
20
20
}
21
21
 
26
26
        MgoSuite
27
27
        HTTPSuite
28
28
        store *store.Store
29
 
        charm *charm.Dir
30
29
}
31
30
 
32
31
type TrivialSuite struct{}
43
42
        c.Assert(err, IsNil)
44
43
        log.Target = c
45
44
        log.Debug = true
46
 
 
47
 
        // A charm to play around with.
48
 
        dir, err := charm.ReadDir(repoDir("dummy"))
49
 
        c.Assert(err, IsNil)
50
 
        s.charm = dir
51
45
}
52
46
 
53
47
func (s *StoreSuite) TearDownTest(c *C) {
58
52
        s.MgoSuite.TearDownTest(c)
59
53
}
60
54
 
61
 
func repoDir(name string) (path string) {
62
 
        return filepath.Join("..", "charm", "testrepo", "series", name)
63
 
}
64
 
 
65
55
// FakeCharmDir is a charm that implements the interface that the
66
56
// store publisher cares about.
67
57
type FakeCharmDir struct {
115
105
        c.Assert(err, IsNil)
116
106
        c.Assert(pub.Revision(), Equals, 0)
117
107
 
118
 
        err = pub.Publish(s.charm)
 
108
        err = pub.Publish(testing.Charms.ClonedDir(c.MkDir(), "dummy"))
119
109
        c.Assert(err, IsNil)
120
110
 
121
111
        for _, url := range urls {