-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
116 lines (109 loc) · 2.54 KB
/
client_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
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
112
113
114
115
116
package verhist
import (
"context"
"os"
"testing"
)
func TestPlatforms(t *testing.T) {
t.Parallel()
var opts []Option
if os.Getenv("VERBOSE") != "" {
opts = append(opts, WithLogf(t.Logf))
}
platforms, err := Platforms(context.Background(), opts...)
if err != nil {
t.Fatalf("expected no error, got: %v", err)
}
for _, platform := range platforms {
t.Logf("name: %s platform: %s", platform.Name, platform.PlatformType)
}
}
func TestChannels(t *testing.T) {
t.Parallel()
var opts []Option
if os.Getenv("VERBOSE") != "" {
opts = append(opts, WithLogf(t.Logf))
}
for _, typ := range platforms() {
t.Run(typ.String(), func(t *testing.T) {
t.Parallel()
channels, err := Channels(context.Background(), typ, opts...)
if err != nil {
t.Fatalf("expected no error, got: %v", err)
}
for _, channel := range channels {
t.Logf("name: %s channel: %s", channel.Name, channel.ChannelType)
}
})
}
}
func TestVersions(t *testing.T) {
t.Parallel()
var opts []Option
if os.Getenv("VERBOSE") != "" {
opts = append(opts, WithLogf(t.Logf))
}
versions, err := Versions(context.Background(), "linux", "stable", opts...)
if err != nil {
t.Fatalf("expected no error, got: %v", err)
}
for _, version := range versions {
t.Logf("name: %s version: %s", version.Name, version.Version)
}
}
func TestLatest(t *testing.T) {
t.Parallel()
var opts []Option
if os.Getenv("VERBOSE") != "" {
opts = append(opts, WithLogf(t.Logf))
}
for _, channel := range []string{"stable", "beta", "dev"} {
t.Run(channel, func(t *testing.T) {
t.Parallel()
latest, err := Latest(context.Background(), "win64", channel, opts...)
if err != nil {
t.Fatalf("expected no error, got: %v", err)
}
t.Logf("name: %s version: %s", latest.Name, latest.Version)
})
}
}
func TestUserAgent(t *testing.T) {
t.Parallel()
var opts []Option
if os.Getenv("VERBOSE") != "" {
opts = append(opts, WithLogf(t.Logf))
}
for _, platform := range []string{"win64", "mac_arm64", "linux", "android"} {
t.Run(platform, func(t *testing.T) {
t.Parallel()
userAgent, err := UserAgent(context.Background(), platform, "stable", opts...)
switch {
case err != nil:
t.Fatalf("expected no error, got: %v", err)
case userAgent == "":
t.Errorf("expected non-empty user agent")
}
t.Logf("user agent: %v", userAgent)
})
}
}
func platforms() []PlatformType {
return []PlatformType{
All,
Android,
ChromeOS,
Fuchsia,
IOS,
LacrosARM32,
LacrosARM64,
Lacros,
Linux,
MacARM64,
Mac,
Webview,
Windows64,
WindowsARM64,
Windows,
}
}