github.com/rogpeppe/juju@v0.0.0-20140613142852-6337964b789e/environs/testing/cloudinit.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package testing 5 6 import ( 7 "github.com/juju/juju/environs" 8 ) 9 10 // PatchDataDir temporarily overrides environs.DataDir for testing purposes. 11 // It returns a cleanup function that you must call later to restore the 12 // original value. 13 func PatchDataDir(path string) func() { 14 originalDataDir := environs.DataDir 15 environs.DataDir = path 16 return func() { environs.DataDir = originalDataDir } 17 }