launchpad.net/~rogpeppe/juju-core/500-errgo-fix@v0.0.0-20140213181702-000000002356/cmd/names_test.go (about) 1 // Copyright 2012, 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package cmd_test 5 6 import ( 7 gc "launchpad.net/gocheck" 8 9 "launchpad.net/juju-core/cmd" 10 ) 11 12 type namesSuite struct { 13 } 14 15 var _ = gc.Suite(&namesSuite{}) 16 17 func (*namesSuite) TestNameChecks(c *gc.C) { 18 assertMachineOrNewContainer := func(s string, expect bool) { 19 c.Assert(cmd.IsMachineOrNewContainer(s), gc.Equals, expect) 20 } 21 assertMachineOrNewContainer("0", true) 22 assertMachineOrNewContainer("00", false) 23 assertMachineOrNewContainer("1", true) 24 assertMachineOrNewContainer("0/lxc/0", true) 25 assertMachineOrNewContainer("lxc:0", true) 26 assertMachineOrNewContainer("lxc:lxc:0", false) 27 assertMachineOrNewContainer("kvm:0/lxc/1", true) 28 assertMachineOrNewContainer("lxc:", false) 29 assertMachineOrNewContainer(":lxc", false) 30 assertMachineOrNewContainer("0/lxc/", false) 31 assertMachineOrNewContainer("0/lxc", false) 32 assertMachineOrNewContainer("kvm:0/lxc", false) 33 assertMachineOrNewContainer("0/lxc/01", false) 34 assertMachineOrNewContainer("0/lxc/10", true) 35 assertMachineOrNewContainer("0/kvm/4", true) 36 }