forked from bitrise-steplib/bitrise-step-android-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
94 lines (69 loc) · 2.25 KB
/
main_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
90
91
92
93
94
package main
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/bitrise-tools/go-android/gradle"
)
func TestFilterVariants(t *testing.T) {
variants := gradle.Variants{
"module1": []string{"variant1", "variant2", "variant3", "variant4", "variant5", "shared"},
"module2": []string{"2variant1", "2variant2", "shared", "2variant3", "2variant4", "2variant5"},
}
t.Log("exact match for module and variant")
{
filtered, err := filterVariants("module1", "variant3", variants)
require.NoError(t, err)
expectedVariants := gradle.Variants{
"module1": []string{"variant3"},
}
require.Equal(t, expectedVariants, filtered)
filtered, err = filterVariants("module1", "variant100", variants)
require.Error(t, err)
filtered, err = filterVariants("module100", "variant100", variants)
require.Error(t, err)
filtered, err = filterVariants("module100", "variant1", variants)
require.Error(t, err)
}
t.Log("exact match for module")
{
filtered, err := filterVariants("module1", "", variants)
require.NoError(t, err)
expectedVariants := gradle.Variants{
"module1": []string{"variant1", "variant2", "variant3", "variant4", "variant5", "shared"},
}
require.Equal(t, expectedVariants, filtered)
filtered, err = filterVariants("module3", "", variants)
require.Error(t, err)
}
t.Log("exact match for variant")
{
filtered, err := filterVariants("", "variant2", variants)
require.NoError(t, err)
expectedVariants := gradle.Variants{
"module1": []string{"variant2"},
}
require.Equal(t, expectedVariants, filtered)
filtered, err = filterVariants("", "", variants)
require.NoError(t, err)
require.Equal(t, variants, filtered)
filtered, err = filterVariants("", "shared", variants)
require.NoError(t, err)
expectedVariants = gradle.Variants{
"module1": []string{"shared"},
"module2": []string{"shared"},
}
require.Equal(t, expectedVariants, filtered)
}
t.Log("check no overlapping variants")
{
variants := gradle.Variants{
"module1": []string{"variant1", "variant12"},
}
filtered, err := filterVariants("module1", "variant1", variants)
require.NoError(t, err)
expectedVariants := gradle.Variants{
"module1": []string{"variant1"},
}
require.Equal(t, expectedVariants, filtered)
}
}