~sinzui/ubuntu/vivid/juju-core/vivid-1.24.6

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cloudconfig/testing/cloudinit.go

  • Committer: Curtis Hovey
  • Date: 2015-09-30 14:14:54 UTC
  • mfrom: (1.1.34)
  • Revision ID: curtis@hovey.name-20150930141454-o3ldf23dzyjio6c0
Backport of 1.24.6 from wily. (LP: #1500916)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013, 2015 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package testing
 
5
 
 
6
import (
 
7
        "github.com/juju/juju/cloudconfig/instancecfg"
 
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 := instancecfg.DataDir
 
15
        instancecfg.DataDir = path
 
16
        return func() { instancecfg.DataDir = originalDataDir }
 
17
}