-
Notifications
You must be signed in to change notification settings - Fork 19
/
config_test.go
89 lines (67 loc) · 2.6 KB
/
config_test.go
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
package main
import (
"testing"
"github.com/bitrise-io/go-xcode/appleauth"
"github.com/stretchr/testify/assert"
)
func Test_GivenAutomaticConnection_WhenParseAuthSources_ThenReceiveAllSources(t *testing.T) {
step := FastlaneRunner{}
expectedValue := []appleauth.Source{
&appleauth.ConnectionAPIKeySource{},
&appleauth.ConnectionAppleIDFastlaneSource{},
&appleauth.InputAPIKeySource{},
&appleauth.InputAppleIDFastlaneSource{},
}
actualValue, err := step.parseAuthSources(automatic)
assert.NoError(t, err)
assert.Equal(t, actualValue, expectedValue)
}
func Test_GivenAPIKeyConnection_WhenParseAuthSources_ThenReceiveConnectionAPIKeySource(t *testing.T) {
step := FastlaneRunner{}
expectedValue := []appleauth.Source{
&appleauth.ConnectionAPIKeySource{},
}
actualValue, err := step.parseAuthSources(apiKey)
assert.NoError(t, err)
assert.Equal(t, expectedValue, actualValue)
}
func Test_GivenAppleIDConnection_WhenParseAuthSources_ThenReceiveAppleIDFastlaneSource(t *testing.T) {
step := FastlaneRunner{}
expectedValue := []appleauth.Source{
&appleauth.ConnectionAppleIDFastlaneSource{},
}
actualValue, err := step.parseAuthSources(appleID)
assert.NoError(t, err)
assert.Equal(t, expectedValue, actualValue)
}
func Test_GivenOffConnection_WhenParseAuthSources_ThenReceiveInputAPIKeyAndAppleIdFastlaneSources(t *testing.T) {
step := FastlaneRunner{}
expectedValue := []appleauth.Source{
&appleauth.InputAPIKeySource{},
&appleauth.InputAppleIDFastlaneSource{},
}
actualValue, err := step.parseAuthSources(off)
assert.NoError(t, err)
assert.Equal(t, expectedValue, actualValue)
}
func Test_GivenGemHomeEnvironmentVariableIsEmpty_WhenValidateGemHome_ThenLogNothing(t *testing.T) {
mockLogger := MockLogger{}
step := FastlaneRunner{logger: &mockLogger}
expectedGemHome := ""
inputs := Inputs{GemHome: expectedGemHome}
config := Config{Inputs: inputs}
step.validateGemHome(config)
mockLogger.AssertNotCalled(t, "Warnf")
}
func Test_GivenGemHomeEnvironmentVariableIsEmpty_WhenValidateGemHome_ThenLogWarning(t *testing.T) {
var mockedLogger MockLogger
step := FastlaneRunner{logger: &mockedLogger}
expectedGemHome := "/Users/test/.gem/"
expectedGemHomeArray := []interface{}{expectedGemHome}
expectedWarningMessage := "GEM_HOME environment variable is set to:\n%s\nThis can lead to errors as gem lookup path may not contain GEM_HOME."
inputs := Inputs{GemHome: expectedGemHome}
config := Config{Inputs: inputs}
mockedLogger.On("Warnf", expectedWarningMessage, expectedGemHomeArray)
step.validateGemHome(config)
mockedLogger.AssertCalled(t, "Warnf", expectedWarningMessage, expectedGemHomeArray)
}