-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobalDetection_test.go
87 lines (83 loc) · 2.51 KB
/
globalDetection_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
package main
import (
decisionmakerPB "code-analyser/protos/pb"
"code-analyser/protos/pb/output/global"
commonUtils "code-analyser/utils"
utilTesting "code-analyser/utils/testing"
"reflect"
"strconv"
"testing"
)
type GlobalDetectionCase struct {
Input string
Output *decisionmakerPB.GlobalDetections
}
var GlobalDetectionCases = []GlobalDetectionCase{
{
Input: commonUtils.RootDirPath() + "/testingRepos/globalDetection/repo1",
Output: &decisionmakerPB.GlobalDetections{
ProcFile: &global.ProcFileOutput{
Used: true,
FilePath: commonUtils.RootDirPath() + "/testingRepos/globalDetection/repo1/Procfile",
Commands: map[string]*global.Command{
"web": {
Command: "bundle",
Args: []string{"exec", "rackup"},
},
"worker": {
Command: "rake",
Args: []string{"resque:work"},
},
},
},
Makefile: &global.MakefileOutput{
Used: true,
FilePath: commonUtils.RootDirPath() + "/testingRepos/globalDetection/repo1/Makefile",
},
DockerFile: &global.DockerFileOutput{
Used: true,
FilePath: commonUtils.RootDirPath() + "/testingRepos/globalDetection/repo1/Dockerfile",
},
DockerComposeFile: &global.DockerComposeFileOutput{
Used: true,
FilePath: commonUtils.RootDirPath() + "/testingRepos/globalDetection/repo1/docker-compose.yml",
},
},
},
{
Input: commonUtils.RootDirPath() + "/testingRepos/emptyRepo",
Output: &decisionmakerPB.GlobalDetections{},
},
}
func TestGlobalDetection(t *testing.T) {
for i, element := range GlobalDetectionCases {
input := element.Input
output := element.Output
t.Run("case "+strconv.Itoa(i), func(t *testing.T) {
t.Parallel()
got := Scrape(input).GloabalDetections
t.Run("procfile", func(t *testing.T) {
t.Parallel()
utilTesting.CheckProcfileEquality(got.ProcFile, output.ProcFile, t)
})
t.Run("makefile", func(t *testing.T) {
t.Parallel()
if !reflect.DeepEqual(got.Makefile, output.Makefile) {
t.Error("expected this ", output.Makefile, "\n got this ", got.Makefile)
}
})
t.Run("dockerComposeFile", func(t *testing.T) {
t.Parallel()
if !reflect.DeepEqual(got.DockerComposeFile, output.DockerComposeFile) {
t.Error("expected this ", output.DockerComposeFile, "\n got this ", got.DockerComposeFile)
}
})
t.Run("dockerFile", func(t *testing.T) {
t.Parallel()
if !reflect.DeepEqual(got.DockerFile, output.DockerFile) {
t.Error("expected this ", output.DockerFile, "\n got this ", got.DockerFile)
}
})
})
}
}