File: envsuite.go

package info (click to toggle)
golang-gopkg-goose.v1 0.0~git20170406.3228e4f-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,116 kB
  • sloc: python: 160; makefile: 3
file content (34 lines) | stat: -rw-r--r-- 628 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package envsuite

// Provides an EnvSuite type which makes sure this test suite gets an isolated
// environment settings. Settings will be saved on start and then cleared, and
// reset on tear down.

import (
	"os"
	"strings"

	gc "gopkg.in/check.v1"
)

type EnvSuite struct {
	environ []string
}

func (s *EnvSuite) SetUpSuite(c *gc.C) {
	s.environ = os.Environ()
}

func (s *EnvSuite) SetUpTest(c *gc.C) {
	os.Clearenv()
}

func (s *EnvSuite) TearDownTest(c *gc.C) {
	for _, envstring := range s.environ {
		kv := strings.SplitN(envstring, "=", 2)
		os.Setenv(kv[0], kv[1])
	}
}

func (s *EnvSuite) TearDownSuite(c *gc.C) {
}