-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain_test.go
More file actions
111 lines (91 loc) · 2.77 KB
/
main_test.go
File metadata and controls
111 lines (91 loc) · 2.77 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package main
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestBuild(t *testing.T) {
t.Log("Build without app path")
{
build, err := build("", SAMPLE_TEST_SUITE, "username", "password")
require.Equal(t, "", build)
require.Error(t, err, FILE_NOT_AVAILABLE_ERROR)
}
t.Log("Build without test_suite_app path")
{
build, err := build(SAMPLE_APP, "", "", "")
require.Equal(t, "", build)
require.Error(t, err, FILE_NOT_AVAILABLE_ERROR)
}
t.Log("Build with invalid credentials")
{
build, err := build(SAMPLE_APP, SAMPLE_TEST_SUITE, "a", "a")
require.Equal(t, build, "{\"message\":\"Unauthorized\"}")
require.NoError(t, err)
}
}
func TestUpload(t *testing.T) {
t.Log("It should throw file not found error with empty path")
{
build, err := upload("", APP_UPLOAD_ENDPOINT, "username", "password")
t.Log(build, err)
require.Equal(t, "", build)
require.Error(t, err)
}
t.Log("It should throw file not found error with invalid path")
{
build, err := upload("invalidpath", APP_UPLOAD_ENDPOINT, "username", "password")
t.Log(build, err)
require.Equal(t, "", build)
require.Error(t, err)
}
}
func TestCheckBuildStatus(t *testing.T) {
t.Log("It should throw FETCH_BUILD_STATUS_ERROR if build_id is not passed")
{
build, err := checkBuildStatus("", "username", "password", false)
t.Log(build, err)
require.Equal(t, "", build)
require.Error(t, err)
}
t.Log("It should throw unauthorized error while checking build status")
{
expected := map[string]interface{}{"message": "unautorized"}
build, err := checkBuildStatus(SAMPLE_BUILD_ID, "username", "password", false)
require.Equal(t, "", build)
require.Error(t, err, expected)
}
}
func TestGetDevices(t *testing.T) {
t.Log("It should return devices list")
{
expected := []string{"Samsung Galaxy S9 Plus-9.0", "Samsung Galaxy S10 Plus-10.0"}
t.Setenv("devices_list", "Samsung Galaxy S9 Plus-9.0\nSamsung Galaxy S10 Plus-10.0")
devices, _ := getDevices()
require.Equal(t, expected, devices)
}
t.Log("It should throw error if devices not found in env")
{
t.Setenv("devices_list", "")
_, err := getDevices()
t.Log(err)
require.Error(t, err)
}
}
func TestLocateTestRunnerFileAndZip(t *testing.T) {
t.Log("It should throw error when test runner file is not found in the path")
{
expected := RUNNER_APP_NOT_FOUND
file_error := locateTestRunnerFileAndZip(TEST_RUNNER_RELATIVE_PATH_BITRISE)
require.Error(t, file_error, expected)
}
t.Log("It should zip the runner when correct path is passed")
{
devices := locateTestRunnerFileAndZip("./test/assets/Tests iOS-Runner.app")
require.NoError(t, devices)
assert.FileExists(t, TEST_RUNNER_ZIP_FILE_NAME)
os.Remove("Tests iOS-Runner.app")
os.Remove("test_suite.zip")
}
}