add new commit

This commit is contained in:
Rasmus Lindroth 2022-05-15 20:44:09 +02:00
parent 7544964508
commit ea59675755
12 changed files with 123 additions and 38 deletions

View file

@ -15,6 +15,7 @@ func TestGetLists(t *testing.T) {
return
}
fmt.Fprintln(w, `[{"id": "1", "title": "foo"}, {"id": "2", "title": "bar"}]`)
return
}))
defer ts.Close()
@ -46,6 +47,7 @@ func TestGetAccountLists(t *testing.T) {
return
}
fmt.Fprintln(w, `[{"id": "1", "title": "foo"}, {"id": "2", "title": "bar"}]`)
return
}))
defer ts.Close()
@ -81,6 +83,7 @@ func TestGetListAccounts(t *testing.T) {
return
}
fmt.Fprintln(w, `[{"username": "foo"}, {"username": "bar"}]`)
return
}))
defer ts.Close()
@ -116,6 +119,7 @@ func TestGetList(t *testing.T) {
return
}
fmt.Fprintln(w, `{"id": "1", "title": "foo"}`)
return
}))
defer ts.Close()
@ -125,11 +129,11 @@ func TestGetList(t *testing.T) {
ClientSecret: "bar",
AccessToken: "zoo",
})
_, err := client.GetList(context.Background(), "2")
list, err := client.GetList(context.Background(), "2")
if err == nil {
t.Fatalf("should be fail: %v", err)
}
list, err := client.GetList(context.Background(), "1")
list, err = client.GetList(context.Background(), "1")
if err != nil {
t.Fatalf("should not be fail: %v", err)
}
@ -145,6 +149,7 @@ func TestCreateList(t *testing.T) {
return
}
fmt.Fprintln(w, `{"id": "1", "title": "foo"}`)
return
}))
defer ts.Close()
@ -154,11 +159,11 @@ func TestCreateList(t *testing.T) {
ClientSecret: "bar",
AccessToken: "zoo",
})
_, err := client.CreateList(context.Background(), "")
list, err := client.CreateList(context.Background(), "")
if err == nil {
t.Fatalf("should be fail: %v", err)
}
list, err := client.CreateList(context.Background(), "foo")
list, err = client.CreateList(context.Background(), "foo")
if err != nil {
t.Fatalf("should not be fail: %v", err)
}
@ -178,6 +183,7 @@ func TestRenameList(t *testing.T) {
return
}
fmt.Fprintln(w, `{"id": "1", "title": "bar"}`)
return
}))
defer ts.Close()
@ -187,11 +193,11 @@ func TestRenameList(t *testing.T) {
ClientSecret: "bar",
AccessToken: "zoo",
})
_, err := client.RenameList(context.Background(), "2", "bar")
list, err := client.RenameList(context.Background(), "2", "bar")
if err == nil {
t.Fatalf("should be fail: %v", err)
}
list, err := client.RenameList(context.Background(), "1", "bar")
list, err = client.RenameList(context.Background(), "1", "bar")
if err != nil {
t.Fatalf("should not be fail: %v", err)
}
@ -210,6 +216,7 @@ func TestDeleteList(t *testing.T) {
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusMethodNotAllowed)
return
}
return
}))
defer ts.Close()
@ -239,6 +246,7 @@ func TestAddToList(t *testing.T) {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
return
}))
defer ts.Close()
@ -264,6 +272,7 @@ func TestRemoveFromList(t *testing.T) {
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusMethodNotAllowed)
return
}
return
}))
defer ts.Close()