@@ -7,7 +7,6 @@ package task
7
7
import (
8
8
"bytes"
9
9
"context"
10
- "encoding/json"
11
10
"flag"
12
11
"fmt"
13
12
"image"
@@ -23,34 +22,6 @@ import (
23
22
)
24
23
25
24
func TestTweetRelease (t * testing.T ) {
26
- if testing .Short () {
27
- // This test is useful when modifying the tweet text and image templates,
28
- // but don't run it in -short mode since—for a New York minute only—this
29
- // test involves making some HTTP GET requests to the internet.
30
- t .Skip ("skipping test that hits go.dev/dl/?mode=json read-only API in -short mode" )
31
- }
32
-
33
- // Fetch real Go release file metadata for use in test cases below.
34
- resp , err := http .Get ("https://go.dev/dl/?mode=json&include=all" )
35
- if err != nil {
36
- t .Fatal (err )
37
- }
38
- defer resp .Body .Close ()
39
- if resp .StatusCode != http .StatusOK {
40
- t .Fatalf ("non-200 OK status code: %v" , resp .Status )
41
- } else if ct := resp .Header .Get ("Content-Type" ); ct != "application/json" {
42
- t .Fatalf ("got Content-Type %q, want %q" , ct , "application/json" )
43
- }
44
- var releases []WebsiteRelease
45
- err = json .NewDecoder (resp .Body ).Decode (& releases )
46
- if err != nil {
47
- t .Fatal (err )
48
- }
49
- var filesByVersion = make (map [string ][]WebsiteFile )
50
- for _ , r := range releases {
51
- filesByVersion [r .Version ] = r .Files
52
- }
53
-
54
25
tests := [... ]struct {
55
26
name string
56
27
published []Published
@@ -62,8 +33,11 @@ func TestTweetRelease(t *testing.T) {
62
33
{
63
34
name : "minor" ,
64
35
published : []Published {
65
- {Version : "go1.17.1" , Files : filesByVersion ["go1.17.1" ]},
66
- {Version : "go1.16.8" , Files : filesByVersion ["go1.16.8" ]},
36
+ {Version : "go1.17.1" , Files : []WebsiteFile {{
37
+ OS : "linux" , Arch : "arm64" ,
38
+ Filename : "go1.17.1.linux-arm64.tar.gz" , Size : 102606384 , Kind : "archive" }},
39
+ },
40
+ {Version : "go1.16.8" },
67
41
},
68
42
security : "Includes security fixes for A and B." ,
69
43
announcement : "https://groups.google.com/g/golang-announce/c/dx9d7IOseHw/m/KNH37k37AAAJ" ,
@@ -90,8 +64,11 @@ $ go1.17.1 version
90
64
go version go1.17.1 linux/arm64` + "\n " ,
91
65
},
92
66
{
93
- name : "minor-solo" ,
94
- published : []Published {{Version : "go1.11.1" , Files : filesByVersion ["go1.11.1" ]}},
67
+ name : "minor-solo" ,
68
+ published : []Published {{Version : "go1.11.1" , Files : []WebsiteFile {{
69
+ OS : "darwin" , Arch : "amd64" ,
70
+ Filename : "go1.11.1.darwin-amd64.tar.gz" , Size : 124181190 , Kind : "archive" }},
71
+ }},
95
72
announcement : "https://groups.google.com/g/golang-announce/c/pFXKAfoVJqw" ,
96
73
randomSeed : 23 ,
97
74
wantLog : `tweet text:
@@ -114,8 +91,11 @@ $ go1.11.1 version
114
91
go version go1.11.1 darwin/amd64` + "\n " ,
115
92
},
116
93
{
117
- name : "beta" ,
118
- published : []Published {{Version : "go1.17beta1" , Files : filesByVersion ["go1.17beta1" ]}},
94
+ name : "beta" ,
95
+ published : []Published {{Version : "go1.17beta1" , Files : []WebsiteFile {{
96
+ OS : "darwin" , Arch : "amd64" ,
97
+ Filename : "go1.17beta1.darwin-amd64.tar.gz" , Size : 135610703 , Kind : "archive" }},
98
+ }},
119
99
announcement : "https://groups.google.com/g/golang-announce/c/i4EliPDV9Ok/m/MxA-nj53AAAJ" ,
120
100
randomSeed : 678 ,
121
101
wantLog : `tweet text:
@@ -140,8 +120,11 @@ $ go1.17beta1 version
140
120
go version go1.17beta1 darwin/amd64` + "\n " ,
141
121
},
142
122
{
143
- name : "rc" ,
144
- published : []Published {{Version : "go1.17rc2" , Files : filesByVersion ["go1.17rc2" ]}},
123
+ name : "rc" ,
124
+ published : []Published {{Version : "go1.17rc2" , Files : []WebsiteFile {{
125
+ OS : "windows" , Arch : "arm64" ,
126
+ Filename : "go1.17rc2.windows-arm64.zip" , Size : 116660997 , Kind : "archive" }},
127
+ }},
145
128
announcement : "https://groups.google.com/g/golang-announce/c/yk30ovJGXWY/m/p9uUnKbbBQAJ" ,
146
129
randomSeed : 456 ,
147
130
wantLog : `tweet text:
@@ -166,8 +149,11 @@ $ go1.17rc2 version
166
149
go version go1.17rc2 windows/arm64` + "\n " ,
167
150
},
168
151
{
169
- name : "major" ,
170
- published : []Published {{Version : "go1.17" , Files : filesByVersion ["go1.17" ]}},
152
+ name : "major" ,
153
+ published : []Published {{Version : "go1.17" , Files : []WebsiteFile {{
154
+ OS : "freebsd" , Arch : "amd64" ,
155
+ Filename : "go1.17.freebsd-amd64.tar.gz" , Size : 133579378 , Kind : "archive" }},
156
+ }},
171
157
security : "Includes a super duper security fix (CVE-123)." ,
172
158
randomSeed : 123 ,
173
159
wantLog : `tweet text:
0 commit comments