-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathanalysis_configuration_test.go
55 lines (48 loc) · 1.29 KB
/
analysis_configuration_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
package codacytool
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLoadAnalysisConfiguration(t *testing.T) {
type testData struct {
fileLocation string
expectedConfiguration AnalysisConfiguration
expectedError string
}
testSet := map[string]testData{
"non-existent": {
fileLocation: "non-existent",
expectedConfiguration: AnalysisConfiguration{},
expectedError: "",
},
"invalid": {
fileLocation: "configuration/invalid",
expectedConfiguration: AnalysisConfiguration{},
expectedError: "invalid character 'i' looking for beginning of value",
},
"empty": {
fileLocation: "configuration/empty",
expectedConfiguration: AnalysisConfiguration{
Files: &[]string{},
Tools: &[]ToolDefinition{},
},
expectedError: "",
},
}
for testName, testData := range testSet {
t.Run(testName, func(t *testing.T) {
// Arrange
runConfig := RunConfiguration{
ToolConfigurationDir: filepath.Join(testsResourcesLocation, testData.fileLocation),
}
// Act
config, err := loadAnalysisConfiguration(runConfig)
// Assert
assert.Equal(t, testData.expectedConfiguration, config)
if err != nil {
assert.Equal(t, testData.expectedError, err.Error())
}
})
}
}