~gophers/goose/unstable-001

« back to all changes in this revision

Viewing changes to testing/envsuite/envsuite.go

  • Committer: John Arbash Meinel
  • Date: 2012-11-18 14:36:52 UTC
  • mfrom: (14.1.3 identity-from-env)
  • Revision ID: john@arbash-meinel.com-20121118143652-zgbcfem2v1m6q700
Implement getting credentials from environment variables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package envsuite
 
2
 
 
3
// Provides an EnvSuite type which makes sure this test suite gets an isolated
 
4
// environment settings. Settings will be saved on start and then cleared, and
 
5
// reset on tear down.
 
6
 
 
7
import (
 
8
        . "launchpad.net/gocheck"
 
9
        "os"
 
10
        "strings"
 
11
)
 
12
 
 
13
type EnvSuite struct {
 
14
        environ []string
 
15
}
 
16
 
 
17
func (s *EnvSuite) SetUpSuite(c *C) {
 
18
        s.environ = os.Environ()
 
19
}
 
20
 
 
21
func (s *EnvSuite) SetUpTest(c *C) {
 
22
        os.Clearenv()
 
23
}
 
24
 
 
25
func (s *EnvSuite) TearDownTest(c *C) {
 
26
        for _, envstring := range s.environ {
 
27
                kv := strings.SplitN(envstring, "=", 2)
 
28
                os.Setenv(kv[0], kv[1])
 
29
        }
 
30
}
 
31
 
 
32
func (s *EnvSuite) TearDownSuite(c *C) {
 
33
}