-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_test.go
43 lines (37 loc) · 1.33 KB
/
app_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
// Test connectivity with both TCP and UDP protocols
func TestConnectivityWithTCPAndUDPProtocols(t *testing.T) {
// Set up test data
setting := &AppSettings{
Configs: []Config{
{
Transport: "ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpLeTUyN2duU3FEVFB3R0JpQ1RxUnlT@104.238.183.16:65496",
TestReports: []*connectivityReport{},
},
{
Transport: "ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpLeTUyN2duU3FEVFB3R0JpQ1RxUnlT@104.238.183.15:65496",
TestReports: []*connectivityReport{},
},
},
ResolverHost: "8.8.8.8",
Domain: "example.com",
}
i := 0
// Run the function under test
TestSingleConfig(setting, i)
// Assert the results
assert.Equal(t, 2, len(setting.Configs[i].TestReports))
assert.Equal(t, "tcp", setting.Configs[i].TestReports[0].Proto)
assert.Equal(t, "udp", setting.Configs[i].TestReports[1].Proto)
assert.Equal(t, true, setting.Configs[i].TestReports[0].IsSuccess())
assert.Equal(t, true, setting.Configs[i].TestReports[1].IsSuccess())
}
func TestCollectReport(t *testing.T) {
r := connectivityReport{Resolver: "8.8.8.8", Proto: "tcp", Transport: "testss://", Error: nil, Collected: false}
u := "https://script.google.com/macros/s/AKfycbzoMBmftQaR9Aw4jzTB-w4TwkDjLHtSfBCFhh4_2NhTEZAUdj85Qt8uYCKCNOEAwCg4/exec"
collectReport(&r, u)
}