-
Notifications
You must be signed in to change notification settings - Fork 22
/
main_test.go
97 lines (82 loc) · 2.31 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
95
96
97
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestPrettyBuildArtifactBasename(t *testing.T) {
require.Equal(t, "app", prettyBuildArtifactBasename("app-unsigned.apk"))
require.Equal(t, "app-signed", prettyBuildArtifactBasename("app-signed.apk"))
require.Equal(t, "app-debug", prettyBuildArtifactBasename("app-debug.apk"))
require.Equal(t, "app-release", prettyBuildArtifactBasename("app-release.apk"))
}
func TestFilterMETAFiles(t *testing.T) {
t.Log("finds files in META-INF folder")
{
fileList := []string{
"META-INF/MANIFEST.MF",
"META-INF/CERT.SF",
"META-INF/CERT.RSA",
"AndroidManifest.xml",
"res/anim/abc_fade_in.xml",
"res/anim/abc_fade_out.xml",
"res/anim/abc_grow_fade_in_from_bottom.xml",
}
metaFiles := filterMETAFiles(fileList)
require.Equal(t, 3, len(metaFiles))
require.Equal(t, "META-INF/MANIFEST.MF", metaFiles[0])
require.Equal(t, "META-INF/CERT.SF", metaFiles[1])
require.Equal(t, "META-INF/CERT.RSA", metaFiles[2])
}
}
func TestFilterSigningFiles(t *testing.T) {
t.Log("finds .mf files")
{
fileList := []string{
"META-INF/MANIFEST.MF",
"res/anim/abc_fade_in.xml",
}
metaFiles := filterSigningFiles(fileList)
require.Equal(t, 1, len(metaFiles))
require.Equal(t, "META-INF/MANIFEST.MF", metaFiles[0])
}
t.Log("finds .rsa files")
{
fileList := []string{
"META-INF/MANIFEST.RSA",
"res/anim/abc_fade_in.xml",
}
metaFiles := filterSigningFiles(fileList)
require.Equal(t, 1, len(metaFiles))
require.Equal(t, "META-INF/MANIFEST.RSA", metaFiles[0])
}
t.Log("finds .dsa files")
{
fileList := []string{
"META-INF/MANIFEST.DSA",
"res/anim/abc_fade_in.xml",
}
metaFiles := filterSigningFiles(fileList)
require.Equal(t, 1, len(metaFiles))
require.Equal(t, "META-INF/MANIFEST.DSA", metaFiles[0])
}
t.Log("finds .ec files")
{
fileList := []string{
"META-INF/MANIFEST.EC",
"res/anim/abc_fade_in.xml",
}
metaFiles := filterSigningFiles(fileList)
require.Equal(t, 1, len(metaFiles))
require.Equal(t, "META-INF/MANIFEST.EC", metaFiles[0])
}
t.Log("finds .sf files")
{
fileList := []string{
"META-INF/MANIFEST.SF",
"res/anim/abc_fade_in.xml",
}
metaFiles := filterSigningFiles(fileList)
require.Equal(t, 1, len(metaFiles))
require.Equal(t, "META-INF/MANIFEST.SF", metaFiles[0])
}
}