-
Notifications
You must be signed in to change notification settings - Fork 0
/
php_test.go
70 lines (65 loc) · 1.49 KB
/
php_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
package labeling
import (
"testing"
"github.com/CircleCI-Public/circleci-config/labeling/labels"
"github.com/google/go-cmp/cmp"
)
func TestCodebase_ApplyPhpRules(t *testing.T) {
tests := []struct {
name string
files map[string]string
expectedLabels []labels.Label
}{
{
name: "phpunit in composer file",
files: map[string]string{
"composer.json": composerWithPhpUnit,
},
expectedLabels: []labels.Label{
{
Key: labels.DepsPhp,
Valid: true,
LabelData: labels.LabelData{
BasePath: ".",
Dependencies: map[string]string{
"laravel/framework": "5.4.*",
"symfony/http-foundation": "3.4.35",
"phpunit/phpunit": "~4.0",
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := fakeCodebase{tt.files}
expected := make(labels.LabelSet)
for _, label := range tt.expectedLabels {
// all should be Valid
label.Valid = true
expected[label.Key] = label
}
got := ApplyAllRules(c)
if diff := cmp.Diff(expected, got); diff != "" {
t.Errorf("ApplyAllRules mismatch (-want +got):\n%s", diff)
}
})
}
}
const composerWithPhpUnit = `
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.4.*",
"symfony/http-foundation": "3.4.35"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
}
}
`