github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/container/kvm/libvert_test.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package kvm_test 5 6 import ( 7 "fmt" 8 "runtime" 9 "strings" 10 11 "github.com/juju/testing" 12 jc "github.com/juju/testing/checkers" 13 gc "gopkg.in/check.v1" 14 15 "github.com/juju/juju/container/kvm" 16 coretesting "github.com/juju/juju/testing" 17 ) 18 19 type LibVertSuite struct { 20 coretesting.BaseSuite 21 ContainerDir string 22 RemovedDir string 23 } 24 25 var _ = gc.Suite(&LibVertSuite{}) 26 27 func (s *LibVertSuite) SetUpTest(c *gc.C) { 28 s.BaseSuite.SetUpTest(c) 29 // Skip if not linux 30 if runtime.GOOS != "linux" { 31 c.Skip("not running linux") 32 } 33 } 34 35 // Test that the call to SyncImages utilizes the defined source 36 func (s *LibVertSuite) TestSyncImagesUtilizesSimpleStreamsSource(c *gc.C) { 37 38 const simpStreamsBinName = "uvt-simplestreams-libvirt" 39 testing.PatchExecutableAsEchoArgs(c, s, simpStreamsBinName) 40 41 const ( 42 series = "mocked-series" 43 arch = "mocked-arch" 44 source = "mocked-url" 45 ) 46 err := kvm.SyncImages(series, arch, source) 47 c.Assert(err, jc.ErrorIsNil) 48 49 expectedArgs := strings.Split( 50 fmt.Sprintf( 51 "sync arch=%s release=%s --source=%s", 52 arch, 53 series, 54 source, 55 ), 56 " ", 57 ) 58 59 testing.AssertEchoArgs(c, simpStreamsBinName, expectedArgs...) 60 }