-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradleparser_test.go
71 lines (64 loc) · 1.22 KB
/
gradleparser_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
package main
import (
"reflect"
"testing"
)
const newGradleFormatKt = `
dependencies {
implementation(project(":cool-beans"))
api(project(":uncool-beans"))
implementation("com.beans.cool")
api("org.beans.cooler")
}
`
const newGradleFormat = `
dependencies {
implementation 'stuff'
api "org.beans.refried:{beansVersion}"
implementation project(':pinto-beans')
api project(':kidney-beans')
}
`
const oldGradleFormat = `
dependencies {
compile project(':pinto-beans')
runtime project(':kidney-beans')
}
`
func TestParser(t *testing.T) {
cases := []struct {
in map[string]string
want map[string][]string
}{
{
map[string]string{
"alpha": newGradleFormatKt,
},
map[string][]string{
"alpha": {"cool-beans", "uncool-beans"},
},
},
{
map[string]string{
"alpha": newGradleFormat,
},
map[string][]string{
"alpha": {"pinto-beans", "kidney-beans"},
},
},
{
map[string]string{
"alpha": oldGradleFormat,
},
map[string][]string{
"alpha": {"pinto-beans", "kidney-beans"},
},
},
}
for _, c := range cases {
got := CreateDependencyMap(c.in)
if !reflect.DeepEqual(got, c.want) {
t.Errorf("CreateDependencyMap(%v) = %v; want %v", c.in, got, c.want)
}
}
}