@@ -12,45 +12,40 @@ import (
12
12
"github.com/stretchr/testify/require"
13
13
)
14
14
15
+ // nolint:paralleltest
15
16
func Test_getAbsoluteBinaryPath (t * testing.T ) {
16
- t .Parallel ()
17
17
type args struct {
18
18
ctx context.Context
19
19
}
20
20
tests := []struct {
21
- name string
22
- args args
23
- terraformVersion string
24
- expectedAbsoluteBinary string
25
- expectedOk bool
21
+ name string
22
+ args args
23
+ terraformVersion string
24
+ expectedOk bool
26
25
}{
27
26
{
28
- name : "TestCorrectVersion" ,
29
- args : args {ctx : context .Background ()},
30
- terraformVersion : "1.1.9" ,
31
- expectedAbsoluteBinary : "" ,
32
- expectedOk : true ,
27
+ name : "TestCorrectVersion" ,
28
+ args : args {ctx : context .Background ()},
29
+ terraformVersion : "1.1.9" ,
30
+ expectedOk : true ,
33
31
},
34
32
{
35
- name : "TestOldVersion" ,
36
- args : args {ctx : context .Background ()},
37
- terraformVersion : "1.0.9" ,
38
- expectedAbsoluteBinary : "" ,
39
- expectedOk : false ,
33
+ name : "TestOldVersion" ,
34
+ args : args {ctx : context .Background ()},
35
+ terraformVersion : "1.0.9" ,
36
+ expectedOk : false ,
40
37
},
41
38
{
42
- name : "TestNewVersion" ,
43
- args : args {ctx : context .Background ()},
44
- terraformVersion : "1.2.9" ,
45
- expectedAbsoluteBinary : "" ,
46
- expectedOk : false ,
39
+ name : "TestNewVersion" ,
40
+ args : args {ctx : context .Background ()},
41
+ terraformVersion : "1.2.9" ,
42
+ expectedOk : false ,
47
43
},
48
44
{
49
- name : "TestMalformedVersion" ,
50
- args : args {ctx : context .Background ()},
51
- terraformVersion : "version" ,
52
- expectedAbsoluteBinary : "" ,
53
- expectedOk : false ,
45
+ name : "TestMalformedVersion" ,
46
+ args : args {ctx : context .Background ()},
47
+ terraformVersion : "version" ,
48
+ expectedOk : false ,
54
49
},
55
50
}
56
51
// nolint:paralleltest
@@ -84,21 +79,18 @@ func Test_getAbsoluteBinaryPath(t *testing.T) {
84
79
pathVariable := os .Getenv ("PATH" )
85
80
t .Setenv ("PATH" , strings .Join ([]string {tempDir , pathVariable }, ":" ))
86
81
82
+ var expectedAbsoluteBinary string
87
83
if tt .expectedOk {
88
- tt . expectedAbsoluteBinary = filepath .Join (tempDir , "terraform" )
84
+ expectedAbsoluteBinary = filepath .Join (tempDir , "terraform" )
89
85
}
90
86
91
87
actualAbsoluteBinary , actualOk := getAbsoluteBinaryPath (tt .args .ctx )
92
- if actualAbsoluteBinary != tt . expectedAbsoluteBinary {
93
- t .Errorf ("getAbsoluteBinaryPath() absoluteBinaryPath, actual = %v, expected %v" , actualAbsoluteBinary , tt . expectedAbsoluteBinary )
88
+ if actualAbsoluteBinary != expectedAbsoluteBinary {
89
+ t .Errorf ("getAbsoluteBinaryPath() absoluteBinaryPath, actual = %v, expected %v" , actualAbsoluteBinary , expectedAbsoluteBinary )
94
90
}
95
91
if actualOk != tt .expectedOk {
96
92
t .Errorf ("getAbsoluteBinaryPath() ok, actual = %v, expected %v" , actualOk , tt .expectedOk )
97
93
}
98
-
99
- t .Cleanup (func () {
100
- t .Setenv ("PATH" , pathVariable )
101
- })
102
94
})
103
95
}
104
96
}
0 commit comments