launchpad.net/~rogpeppe/juju-core/500-errgo-fix@v0.0.0-20140213181702-000000002356/environs/manual/addresses_test.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package manual_test 5 6 import ( 7 gc "launchpad.net/gocheck" 8 9 "launchpad.net/juju-core/environs/manual" 10 "launchpad.net/juju-core/instance" 11 "launchpad.net/juju-core/testing/testbase" 12 ) 13 14 type addressesSuite struct { 15 testbase.LoggingSuite 16 } 17 18 var _ = gc.Suite(&addressesSuite{}) 19 20 func (s *addressesSuite) TestHostAddresses(c *gc.C) { 21 const hostname = "boxen0" 22 s.PatchValue(manual.InstanceHostAddresses, func(host string) ([]instance.Address, error) { 23 c.Check(host, gc.Equals, hostname) 24 return []instance.Address{ 25 instance.NewAddress("192.168.0.1"), 26 instance.NewAddress("nickname"), 27 instance.NewAddress(hostname), 28 }, nil 29 }) 30 addrs, err := manual.HostAddresses(hostname) 31 c.Assert(err, gc.IsNil) 32 c.Assert(addrs, gc.HasLen, 3) 33 // The last address is marked public, all others are unknown. 34 c.Assert(addrs[0].NetworkScope, gc.Equals, instance.NetworkUnknown) 35 c.Assert(addrs[1].NetworkScope, gc.Equals, instance.NetworkUnknown) 36 c.Assert(addrs[2].NetworkScope, gc.Equals, instance.NetworkPublic) 37 }