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

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/migration_internal_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
package state
5
5
 
6
6
import (
7
 
        "reflect"
8
 
 
9
7
        "github.com/juju/utils/set"
10
8
        gc "gopkg.in/check.v1"
11
9
        "gopkg.in/juju/charm.v6-unstable"
 
10
 
 
11
        "github.com/juju/juju/testing"
12
12
)
13
13
 
14
14
type MigrationSuite struct{}
19
19
        completedCollections := set.NewStrings(
20
20
                annotationsC,
21
21
                blocksC,
 
22
                cloudimagemetadataC,
22
23
                constraintsC,
23
24
                modelsC,
24
25
                modelUsersC,
55
56
                // storage
56
57
                blockDevicesC,
57
58
 
 
59
                // cloudimagemetadata
 
60
                cloudimagemetadataC,
 
61
 
58
62
                // actions
59
63
                actionsC,
60
64
 
73
77
                // machine removals.
74
78
                cleanupsC,
75
79
                machineRemovalsC,
 
80
                // The autocert cache is non-critical. After migration
 
81
                // you'll just need to acquire new certificates.
 
82
                autocertCacheC,
76
83
                // We don't export the controller model at this stage.
77
84
                controllersC,
78
85
                // Clouds aren't migrated. They must exist in the
155
162
                // model configuration
156
163
                globalSettingsC,
157
164
 
158
 
                // model
159
 
                cloudimagemetadataC,
160
 
 
161
165
                // machine
162
166
                rebootC,
163
167
 
792
796
}
793
797
 
794
798
func (s *MigrationSuite) AssertExportedFields(c *gc.C, doc interface{}, fields set.Strings) {
795
 
        expected := getExportedFields(doc)
 
799
        expected := testing.GetExportedFields(doc)
796
800
        unknown := expected.Difference(fields)
797
801
        removed := fields.Difference(expected)
798
802
        // If this test fails, it means that extra fields have been added to the
800
804
        c.Check(unknown, gc.HasLen, 0)
801
805
        c.Assert(removed, gc.HasLen, 0)
802
806
}
803
 
 
804
 
func getExportedFields(arg interface{}) set.Strings {
805
 
        t := reflect.TypeOf(arg)
806
 
        result := set.NewStrings()
807
 
 
808
 
        count := t.NumField()
809
 
        for i := 0; i < count; i++ {
810
 
                f := t.Field(i)
811
 
                // empty PkgPath means exported field.
812
 
                // see https://golang.org/pkg/reflect/#StructField
813
 
                if f.PkgPath == "" {
814
 
                        result.Add(f.Name)
815
 
                }
816
 
        }
817
 
 
818
 
        return result
819
 
}