Skip to content

Commit 9fd87fa

Browse files
committed
wip tests
1 parent 425f707 commit 9fd87fa

2 files changed

Lines changed: 55 additions & 8 deletions

File tree

pkg/cmd/gist/list/http.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func listGists(client *http.Client, hostname string, limit int, visibility strin
2020
query.Add("per_page", "100")
2121
}
2222

23+
// TODO switch to graphql
2324
apiClient := api.NewClientFromHTTP(client)
2425
err := apiClient.REST(hostname, "GET", "gists?"+query.Encode(), nil, &result)
2526
if err != nil {

pkg/cmd/gist/list/list_test.go

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,32 @@ func Test_listRun(t *testing.T) {
106106
},
107107
wantOut: "",
108108
},
109-
110109
{
111110
name: "default behavior",
112111
opts: &ListOptions{},
113-
wantOut: "TODO",
112+
wantOut: "1234567890 1 file public about 6 hours ago\n2345678901 tea leaves thwart... 2 files secret about 6 hours ago\n3456789012 short desc 11 files secret about 6 hours ago\n",
113+
},
114+
{
115+
name: "with public filter",
116+
opts: &ListOptions{Visibility: "public"},
117+
wantOut: "1234567890 1 file public about 6 hours ago\n",
118+
},
119+
{
120+
name: "with secret filter",
121+
opts: &ListOptions{Visibility: "secret"},
122+
wantOut: "2345678901 tea leaves thwart... 2 files secret about 6 hours ago\n3456789012 short desc 11 files secret about 6 hours ago\n",
123+
},
124+
{
125+
name: "with limit",
126+
opts: &ListOptions{Limit: 1},
127+
wantOut: "1234567890 1 file public about 6 hours ago\n",
128+
},
129+
{
130+
name: "nontty output",
131+
opts: &ListOptions{},
132+
wantOut: "",
133+
nontty: true,
114134
},
115-
// TODO public filter
116-
// TODO secret filter
117-
// TODO limit specified
118-
// TODO nontty output
119135
}
120136

121137
for _, tt := range tests {
@@ -131,8 +147,38 @@ func Test_listRun(t *testing.T) {
131147
Content: "lol",
132148
},
133149
},
134-
Public: true,
135-
UpdatedAt: time.Time{},
150+
Public: true,
151+
},
152+
{
153+
ID: "2345678901",
154+
Description: "tea leaves thwart those who court catastrophe",
155+
Files: map[string]*shared.GistFile{
156+
"gistfile0.txt": {
157+
Content: "lolol",
158+
},
159+
"gistfile1.txt": {
160+
Content: "lololol",
161+
},
162+
},
163+
Public: false,
164+
},
165+
{
166+
ID: "3456789012",
167+
Description: "short desc",
168+
Files: map[string]*shared.GistFile{
169+
"gistfile0.txt": {},
170+
"gistfile1.txt": {},
171+
"gistfile2.txt": {},
172+
"gistfile3.txt": {},
173+
"gistfile4.txt": {},
174+
"gistfile5.txt": {},
175+
"gistfile6.txt": {},
176+
"gistfile7.txt": {},
177+
"gistfile8.txt": {},
178+
"gistfile9.txt": {},
179+
"gistfile10.txt": {},
180+
},
181+
Public: false,
136182
},
137183
}))
138184
} else {

0 commit comments

Comments
 (0)