-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcall_test.go
62 lines (56 loc) · 1.8 KB
/
call_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
package zoom
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestExtractZoomCallData(t *testing.T) {
examples := []struct {
input string
expected call
}{
{"https://github.com", call{}},
{
"\n\n\nConference: https://zoom.us/j/9851224\n\n",
call{id: "9851224", originalURL: "https://zoom.us/j/9851224"},
},
{
"\n\n\nConference: https://usweb04.zoom.us/j/2315\n\n",
call{id: "2315", originalURL: "https://usweb04.zoom.us/j/2315"},
},
{
"\n\n\nConference: https://jithub.zoom.us/j/12345\n\n",
call{id: "12345", originalURL: "https://jithub.zoom.us/j/12345"},
},
{
"\nhttps://github.com\nConf:https://jithub.zoom.us/j/42124?pwd=ZXN2S0k1AzU1ZitEKUhTR0NMZ2NwZz09\n",
call{id: "42124", password: "ZXN2S0k1AzU1ZitEKUhTR0NMZ2NwZz09", originalURL: "https://jithub.zoom.us/j/42124?pwd=ZXN2S0k1AzU1ZitEKUhTR0NMZ2NwZz09"},
},
{
"\n\nConf:https://jithub.zoom.us/my/foobar\n",
call{originalURL: "https://jithub.zoom.us/my/foobar"},
},
{
"\n\nConf:https://jithub.zoom.us/my/foobar?pwd=ZXN2S0k1AzU1ZitEKUhTR0NMZ2NwZz09\n",
call{password: "ZXN2S0k1AzU1ZitEKUhTR0NMZ2NwZz09", originalURL: "https://jithub.zoom.us/my/foobar?pwd=ZXN2S0k1AzU1ZitEKUhTR0NMZ2NwZz09"},
},
}
for _, example := range examples {
actual, _ := extractZoomCallData(example.input)
assert.Equal(t, example.expected, actual)
}
}
func TestCallGetAppURL(t *testing.T) {
examples := []struct {
input call
expected string
}{
{call{}, ""},
{call{originalURL: "foo"}, "foo"},
{call{originalURL: "foo", id: "1234"}, "zoommtg://zoom.us/join?confno=1234"},
{call{originalURL: "foo", id: "1234", password: "baz"}, "zoommtg://zoom.us/join?confno=1234&pwd=baz"},
}
for _, example := range examples {
actual := example.input.GetAppURL()
assert.Equal(t, example.expected, actual)
}
}