~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/core/modelmigration/phase_internal_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2016 Canonical Ltd.
2
 
// Licensed under the AGPLv3, see LICENCE file for details.
3
 
 
4
 
package modelmigration
5
 
 
6
 
import (
7
 
        "github.com/juju/utils/set"
8
 
        gc "gopkg.in/check.v1"
9
 
 
10
 
        coretesting "github.com/juju/juju/testing"
11
 
)
12
 
 
13
 
type PhaseInternalSuite struct {
14
 
        coretesting.BaseSuite
15
 
}
16
 
 
17
 
var _ = gc.Suite(new(PhaseInternalSuite))
18
 
 
19
 
func (s *PhaseInternalSuite) TestForUnused(c *gc.C) {
20
 
        usedPhases := set.NewStrings()
21
 
        for source, targets := range validTransitions {
22
 
                usedPhases.Add(source.String())
23
 
                for _, target := range targets {
24
 
                        usedPhases.Add(target.String())
25
 
                }
26
 
        }
27
 
 
28
 
        allValidPhases := set.NewStrings(phaseNames...)
29
 
        allValidPhases.Remove(UNKNOWN.String())
30
 
        unused := allValidPhases.Difference(usedPhases)
31
 
        c.Check(unused, gc.HasLen, 0)
32
 
}
33
 
 
34
 
func (s *PhaseInternalSuite) TestForUnreachable(c *gc.C) {
35
 
        const initialPhase = QUIESCE
36
 
        allSources := set.NewStrings()
37
 
        allTargets := set.NewStrings()
38
 
        for source, targets := range validTransitions {
39
 
                if source != initialPhase {
40
 
                        allSources.Add(source.String())
41
 
                }
42
 
                for _, target := range targets {
43
 
                        allTargets.Add(target.String())
44
 
                }
45
 
        }
46
 
 
47
 
        // Each source must be referred to at least once.
48
 
        c.Check(allSources.Difference(allTargets), gc.HasLen, 0)
49
 
}