-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtestaddon_test.go
72 lines (66 loc) · 1.84 KB
/
testaddon_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
package main
import (
"testing"
)
func TestGetVariantDir(t *testing.T) {
tc := []struct {
title string
path string
wantStr string
isErr bool
}{
{
title: "should return variant dir",
path: "./app/build/test-results/testDebugUnitTest/TEST-sample.results.test.multiple.bitrise.com.multipletestresultssample.UnitTest0.xml",
wantStr: "app-debug",
isErr: false,
},
{
title: "should return error on empty string",
path: "",
wantStr: "",
isErr: true,
},
{
title: "should return error for non default Local Android Unit result XML path",
path: "/path/to/test-results/",
wantStr: "",
isErr: true,
},
{
title: "should return error for non default Local Android Unit result XML path",
path: "./app/build/test-results/jacocoTestReleaseUnitTestReport/jacocoTestReleaseUnitTestReport.xml",
wantStr: "",
isErr: true,
},
}
for _, tt := range tc {
str, err := getVariantDir(tt.path)
if str != tt.wantStr || (err != nil) != tt.isErr {
t.Fatalf("%s: got (%s, %s)", tt.title, str, err)
}
}
}
func TestGetExportDir(t *testing.T) {
tc := []struct {
title string
artifactPath string
want string
}{
{
title: "should return 'other' for non mappable result path",
artifactPath: "./app/build/test-results/jacocoTestReleaseUnitTestReport/jacocoTestReleaseUnitTestReport.xml",
want: "other",
},
{
title: "should return string in <module>-<variant> for android result path",
artifactPath: "./app/build/test-results/testDemoDebugUnitTest/TEST-sample.results.test.multiple.bitrise.com.multipletestresultssample.UnitTest0.xml",
want: "app-demoDebug",
},
}
for _, tt := range tc {
if got := getExportDir(tt.artifactPath); got != tt.want {
t.Fatalf("%s: got '%s' want '%s'", tt.title, got, tt.want)
}
}
}