Ubuntu Pastebin

Paste from Chipaca at Tue, 1 Sep 2015 11:39:46 +0000

Download as text
 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
=== modified file '_integration-tests/testutils/build/build_test.go'
--- _integration-tests/testutils/build/build_test.go	2015-08-24 14:38:20 +0000
+++ _integration-tests/testutils/build/build_test.go	2015-09-01 11:38:58 +0000
@@ -31,6 +31,37 @@
 // Hook up check.v1 into the "go test" runner
 func Test(t *testing.T) { check.TestingT(t) }
 
+type envir1 struct {
+	cur  string // lazy
+	nget int
+	set  []string
+}
+
+type trackingEnviron map[string]*envir1
+
+func (e trackingEnviron) set(key string, value string) error {
+	_, ok := e[key]
+	if !ok {
+		e[key] = &envir1{}
+	}
+
+	e[key].set = append(e[key].set, value)
+	e[key].cur = value
+
+	return nil
+}
+
+func (e trackingEnviron) get(key string) string {
+	_, ok := e[key]
+	if !ok {
+		e[key] = &envir1{}
+	}
+
+	e[key].nget++
+
+	return e[key].cur
+}
+
 type BuildSuite struct {
 	execCalls        map[string]int
 	execReturnValues []string
@@ -43,11 +74,9 @@
 	osRenameCalls map[string]int
 	backOsRename  func(string, string) error
 
-	osSetenvCalls map[string]int
-	backOsSetenv  func(string, string) error
-
-	osGetenvCalls map[string]int
-	backOsGetenv  func(string) string
+	backOsSetenv func(string, string) error
+	backOsGetenv func(string) string
+	environ      map[string]environtrack
 
 	useSnappyFromBranch bool
 	arch                string
@@ -65,8 +94,6 @@
 	execCommand = s.fakeExecCommand
 	prepareTargetDir = s.fakePrepareTargetDir
 	osRename = s.fakeOsRename
-	osSetenv = s.fakeOsSetenv
-	osGetenv = s.fakeOsGetenv
 }
 
 func (s *BuildSuite) TearDownSuite(c *check.C) {
@@ -81,8 +108,9 @@
 	s.execCalls = make(map[string]int)
 	s.mkDirCalls = make(map[string]int)
 	s.osRenameCalls = make(map[string]int)
-	s.osSetenvCalls = make(map[string]int)
-	s.osGetenvCalls = make(map[string]int)
+	s.environ = make(trackingEnviron)
+	osSetenv = s.environ.set
+	osGetenv = s.environ.get
 }
 
 func (s *BuildSuite) fakeExecCommand(args ...string) (err error) {
@@ -99,16 +127,6 @@
 	return
 }
 
-func (s *BuildSuite) fakeOsSetenv(key, value string) (err error) {
-	s.osSetenvCalls[key+" "+value]++
-	return
-}
-
-func (s *BuildSuite) fakeOsGetenv(key string) (value string) {
-	s.osGetenvCalls[key]++
-	return
-}
-
 func (s *BuildSuite) TestAssetsCallsPrepareDir(c *check.C) {
 	Assets(s.useSnappyFromBranch, s.arch)
 
Download as text