github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/provider/local/export_test.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 package local 4 5 import ( 6 "github.com/juju/testing" 7 gc "launchpad.net/gocheck" 8 9 "github.com/juju/juju/environs/config" 10 ) 11 12 var ( 13 CheckIfRoot = &checkIfRoot 14 CheckLocalPort = &checkLocalPort 15 DetectAptProxies = &detectAptProxies 16 FinishBootstrap = &finishBootstrap 17 Provider = providerInstance 18 UserCurrent = &userCurrent 19 ) 20 21 // ConfigNamespace returns the result of the namespace call on the 22 // localConfig. 23 func ConfigNamespace(cfg *config.Config) string { 24 env, _ := providerInstance.Open(cfg) 25 return env.(*localEnviron).config.namespace() 26 } 27 28 // CreateDirs calls createDirs on the localEnviron. 29 func CreateDirs(c *gc.C, cfg *config.Config) error { 30 env, err := providerInstance.Open(cfg) 31 c.Assert(err, gc.IsNil) 32 return env.(*localEnviron).config.createDirs() 33 } 34 35 // CheckDirs returns the list of directories to check for permissions in the test. 36 func CheckDirs(c *gc.C, cfg *config.Config) []string { 37 localConfig, err := providerInstance.newConfig(cfg) 38 c.Assert(err, gc.IsNil) 39 return []string{ 40 localConfig.rootDir(), 41 localConfig.storageDir(), 42 localConfig.mongoDir(), 43 } 44 } 45 46 // MockAddressForInterface replaces the getAddressForInterface with a function 47 // that returns a constant localhost ip address. 48 func MockAddressForInterface() func() { 49 return testing.PatchValue(&getAddressForInterface, func(name string) (string, error) { 50 logger.Debugf("getAddressForInterface called for %s", name) 51 return "127.0.0.1", nil 52 }) 53 }