wip tests

This commit is contained in:
vilmibm 2020-09-15 14:15:44 -05:00
parent 425f707c7d
commit 9fd87faadc
2 changed files with 55 additions and 8 deletions

View file

@ -20,6 +20,7 @@ func listGists(client *http.Client, hostname string, limit int, visibility strin
query.Add("per_page", "100")
}
// TODO switch to graphql
apiClient := api.NewClientFromHTTP(client)
err := apiClient.REST(hostname, "GET", "gists?"+query.Encode(), nil, &result)
if err != nil {

View file

@ -106,16 +106,32 @@ func Test_listRun(t *testing.T) {
},
wantOut: "",
},
{
name: "default behavior",
opts: &ListOptions{},
wantOut: "TODO",
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",
},
{
name: "with public filter",
opts: &ListOptions{Visibility: "public"},
wantOut: "1234567890 1 file public about 6 hours ago\n",
},
{
name: "with secret filter",
opts: &ListOptions{Visibility: "secret"},
wantOut: "2345678901 tea leaves thwart... 2 files secret about 6 hours ago\n3456789012 short desc 11 files secret about 6 hours ago\n",
},
{
name: "with limit",
opts: &ListOptions{Limit: 1},
wantOut: "1234567890 1 file public about 6 hours ago\n",
},
{
name: "nontty output",
opts: &ListOptions{},
wantOut: "",
nontty: true,
},
// TODO public filter
// TODO secret filter
// TODO limit specified
// TODO nontty output
}
for _, tt := range tests {
@ -131,8 +147,38 @@ func Test_listRun(t *testing.T) {
Content: "lol",
},
},
Public: true,
UpdatedAt: time.Time{},
Public: true,
},
{
ID: "2345678901",
Description: "tea leaves thwart those who court catastrophe",
Files: map[string]*shared.GistFile{
"gistfile0.txt": {
Content: "lolol",
},
"gistfile1.txt": {
Content: "lololol",
},
},
Public: false,
},
{
ID: "3456789012",
Description: "short desc",
Files: map[string]*shared.GistFile{
"gistfile0.txt": {},
"gistfile1.txt": {},
"gistfile2.txt": {},
"gistfile3.txt": {},
"gistfile4.txt": {},
"gistfile5.txt": {},
"gistfile6.txt": {},
"gistfile7.txt": {},
"gistfile8.txt": {},
"gistfile9.txt": {},
"gistfile10.txt": {},
},
Public: false,
},
}))
} else {