-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutilsCheckVersion_test.go
More file actions
51 lines (48 loc) · 1.18 KB
/
utilsCheckVersion_test.go
File metadata and controls
51 lines (48 loc) · 1.18 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
package pighosts
import (
"io/ioutil"
"net/http"
"strings"
"testing"
"time"
)
func TestGetVersion(t *testing.T) {
timeout := time.Duration(5 * time.Second)
client := http.Client{
Timeout: timeout,
}
defer client.CloseIdleConnections()
resp, _ := client.Get("https://raw.githubusercontent.com/goldfix/pigHosts/master/VERSION")
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
result := strings.TrimSpace(string(body))
type args struct {
currentVer string
}
tests := []struct {
name string
args args
want bool
want1 string
wantErr bool
}{
{"TestGetVersion_1", args{"dev"}, false, result, false},
{"TestGetVersion_2", args{result}, false, result, false},
{"TestGetVersion_3", args{"1.0"}, true, result, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, got1, err := GetVersion(tt.args.currentVer)
if (err != nil) != tt.wantErr {
t.Errorf("GetVersion() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("GetVersion() got = %v, want %v", got, tt.want)
}
if got1 != tt.want1 {
t.Errorf("GetVersion() got1 = %v, want %v", got1, tt.want1)
}
})
}
}