1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package environs_test
import (
gc "launchpad.net/gocheck"
"launchpad.net/juju-core/environs"
"launchpad.net/juju-core/provider/dummy"
"launchpad.net/juju-core/testing"
"launchpad.net/juju-core/version"
)
type MongoToolsSuite struct {
env environs.Environ
testing.LoggingSuite
dataDir string
}
func (t *MongoToolsSuite) SetUpTest(c *gc.C) {
t.LoggingSuite.SetUpTest(c)
env, err := environs.NewFromAttrs(map[string]interface{}{
"name": "test",
"type": "dummy",
"state-server": false,
"authorized-keys": "i-am-a-key",
"ca-cert": testing.CACert,
"ca-private-key": "",
})
c.Assert(err, gc.IsNil)
t.env = env
t.dataDir = c.MkDir()
}
func (t *MongoToolsSuite) TearDownTest(c *gc.C) {
dummy.Reset()
t.LoggingSuite.TearDownTest(c)
}
func currentMongoPath() string {
return environs.MongoStoragePath(version.CurrentSeries(), version.CurrentArch())
}
var mongoURLTests = []struct {
summary string // a summary of the test purpose.
contents []string // names in private storage.
publicContents []string // names in public storage.
expect string // the name we expect to find (if no error).
urlpart string // part of the url we expect to find (if not blank).
}{{
summary: "grab mongo from private storage if it exists there",
contents: []string{currentMongoPath()},
expect: currentMongoPath(),
}, {
summary: "fall back to public storage when nothing found in private",
contents: []string{
environs.MongoStoragePath("foo", version.CurrentArch()),
},
publicContents: []string{
currentMongoPath(),
},
expect: "public-" + currentMongoPath(),
}, {
summary: "if nothing in public or private storage, fall back to copy in ec2",
contents: []string{
environs.MongoStoragePath("foo", version.CurrentArch()),
environs.MongoStoragePath(version.CurrentSeries(), "foo"),
},
publicContents: []string{
environs.MongoStoragePath("foo", version.CurrentArch()),
},
urlpart: "http://juju-dist.s3.amazonaws.com",
},
}
|