~themue/juju-core/053-env-more-script-friendly

« back to all changes in this revision

Viewing changes to state/state_test.go

  • Committer: Dimiter Naydenov
  • Date: 2013-07-29 15:15:41 UTC
  • mto: This revision was merged to the branch mainline in revision 1565.
  • Revision ID: dimiter.naydenov@canonical.com-20130729151541-zm8murwo9u7mtsdu
names: new package

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
        "launchpad.net/juju-core/environs/config"
20
20
        "launchpad.net/juju-core/errors"
21
21
        "launchpad.net/juju-core/instance"
 
22
        "launchpad.net/juju-core/names"
22
23
        "launchpad.net/juju-core/state"
23
24
        "launchpad.net/juju-core/state/api/params"
24
25
        statetesting "launchpad.net/juju-core/state/testing"
1047
1048
 
1048
1049
func (*StateSuite) TestNameChecks(c *gc.C) {
1049
1050
        assertService := func(s string, expect bool) {
1050
 
                c.Assert(state.IsServiceName(s), gc.Equals, expect)
 
1051
                c.Assert(names.IsServiceName(s), gc.Equals, expect)
1051
1052
                // Check that anything that is considered a valid service name
1052
1053
                // is also (in)valid if a(n) (in)valid unit designator is added
1053
1054
                // to it.
1054
 
                c.Assert(state.IsUnitName(s+"/0"), gc.Equals, expect)
1055
 
                c.Assert(state.IsUnitName(s+"/99"), gc.Equals, expect)
1056
 
                c.Assert(state.IsUnitName(s+"/-1"), gc.Equals, false)
1057
 
                c.Assert(state.IsUnitName(s+"/blah"), gc.Equals, false)
1058
 
                c.Assert(state.IsUnitName(s+"/"), gc.Equals, false)
 
1055
                c.Assert(names.IsUnitName(s+"/0"), gc.Equals, expect)
 
1056
                c.Assert(names.IsUnitName(s+"/99"), gc.Equals, expect)
 
1057
                c.Assert(names.IsUnitName(s+"/-1"), gc.Equals, false)
 
1058
                c.Assert(names.IsUnitName(s+"/blah"), gc.Equals, false)
 
1059
                c.Assert(names.IsUnitName(s+"/"), gc.Equals, false)
1059
1060
        }
1060
1061
        // Service names must be non-empty...
1061
1062
        assertService("", false)
1079
1080
        assertService("foo-2", false)
1080
1081
 
1081
1082
        assertMachine := func(s string, expect bool) {
1082
 
                c.Assert(state.IsMachineId(s), gc.Equals, expect)
 
1083
                c.Assert(names.IsMachineId(s), gc.Equals, expect)
1083
1084
        }
1084
1085
        assertMachine("0", true)
1085
1086
        assertMachine("00", false)
1104
1105
        assertMachine("0/lxc/1/embedded/2", true)
1105
1106
 
1106
1107
        assertMachineOrNewContainer := func(s string, expect bool) {
1107
 
                c.Assert(state.IsMachineOrNewContainer(s), gc.Equals, expect)
 
1108
                c.Assert(names.IsMachineOrNewContainer(s), gc.Equals, expect)
1108
1109
        }
1109
1110
        assertMachineOrNewContainer("0", true)
1110
1111
        assertMachineOrNewContainer("00", false)