-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpinger_test.go
More file actions
31 lines (27 loc) · 912 Bytes
/
pinger_test.go
File metadata and controls
31 lines (27 loc) · 912 Bytes
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
package main
import (
"testing"
)
func TestGetPingSuccess(t *testing.T) {
response := getPing("https://ifmo.su")
if !response.result {
t.Errorf("Response should be true, but it is %t", response.result)
t.Errorf("Ping get failed: code=%d, message=%s.", response.statusCode, response.message)
}
}
func TestGetPingDNSFail(t *testing.T) {
response := getPing("https://undefined.undefined")
if response.result {
t.Errorf("Response should be false, but it is %t", response.result)
// t.Errorf("Ping get success: code=%d, message=%s.", response.statusCode, response.message)
}
if response.statusCode != 0 {
t.Errorf("Response statusCode should be 0, but it is %d", response.statusCode)
}
}
func TestGetPing404Error(t *testing.T) {
response := getPing("https://hawk.so/123")
if response.statusCode != 404 {
t.Errorf("Response statusCode should be 404, but it is %d", response.statusCode)
}
}