-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump_test.go
47 lines (37 loc) · 1.24 KB
/
dump_test.go
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
// Copyright 2016 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package state_test
import (
"time"
"github.com/juju/collections/set"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/state"
)
type dumpSuite struct {
ConnSuite
}
var _ = gc.Suite(&dumpSuite{})
func (s *dumpSuite) TestDumpAll(c *gc.C) {
// Some of the state workers are responsible for creating
// collections, so make sure they've started before running
// the dump.
state.EnsureWorkersStarted(s.State)
// Make a leadership claim. No leases until we do.
claimer := s.State.LeadershipClaimer()
err := claimer.ClaimLeadership("app", "app/0", time.Minute)
c.Assert(err, jc.ErrorIsNil)
value, err := s.State.DumpAll()
c.Assert(err, jc.ErrorIsNil)
models, ok := value["models"].(map[string]interface{})
c.Assert(ok, jc.IsTrue)
c.Assert(models["name"], gc.Equals, "testmodel")
initialCollections := set.NewStrings()
for name := range value {
initialCollections.Add(name)
}
// check that there are some other collections there
c.Check(initialCollections.Contains("modelusers"), jc.IsTrue)
c.Check(initialCollections.Contains("leases"), jc.IsTrue)
c.Check(initialCollections.Contains("statuses"), jc.IsTrue)
}