Skip to content

Commit

Permalink
Remove global context in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Prylutskyi Anatolii committed Sep 25, 2016
1 parent 67b650e commit 84ac3b0
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions asana/asana_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var (
client *Client
mux *http.ServeMux
server *httptest.Server
ctx = context.Background()
)

func setup() {
Expand Down Expand Up @@ -59,7 +58,7 @@ func TestListWorkspaces(t *testing.T) {
]}`)
})

workspaces, err := client.ListWorkspaces(ctx)
workspaces, err := client.ListWorkspaces(context.Background())
if err != nil {
t.Errorf("ListWorkspaces returned error: %v", err)
}
Expand All @@ -85,7 +84,7 @@ func TestListUsers(t *testing.T) {
]}`)
})

users, err := client.ListUsers(ctx, nil)
users, err := client.ListUsers(context.Background(), nil)
if err != nil {
t.Errorf("ListUsers returned error: %v", err)
}
Expand All @@ -111,7 +110,7 @@ func TestListProjects(t *testing.T) {
]}`)
})

projects, err := client.ListProjects(ctx, nil)
projects, err := client.ListProjects(context.Background(), nil)
if err != nil {
t.Errorf("ListProjects returned error: %v", err)
}
Expand All @@ -137,7 +136,7 @@ func TestListTasks(t *testing.T) {
]}`)
})

tasks, err := client.ListTasks(ctx, nil)
tasks, err := client.ListTasks(context.Background(), nil)
if err != nil {
t.Errorf("ListTasks returned error: %v", err)
}
Expand Down Expand Up @@ -180,7 +179,7 @@ func TestUpdateTask(t *testing.T) {
// to store v and returns a pointer to it.
String := func(v string) *string { return &v }

task, err := client.UpdateTask(ctx, 1, TaskUpdate{Notes: String("updated notes")}, nil)
task, err := client.UpdateTask(context.Background(), 1, TaskUpdate{Notes: String("updated notes")}, nil)
if err != nil {
t.Errorf("UpdateTask returned error: %v", err)
}
Expand All @@ -202,7 +201,7 @@ func TestListTags(t *testing.T) {
]}`)
})

tags, err := client.ListTags(ctx, nil)
tags, err := client.ListTags(context.Background(), nil)
if err != nil {
t.Errorf("ListTags returned error: %v", err)
}
Expand All @@ -225,7 +224,7 @@ func TestUnauthorized(t *testing.T) {
w.WriteHeader(http.StatusUnauthorized)
})

_, err := client.ListTags(ctx, nil)
_, err := client.ListTags(context.Background(), nil)
if err != ErrUnauthorized {
t.Errorf("Unexpected err %v", err)
}
Expand Down Expand Up @@ -260,7 +259,7 @@ func TestCreateTask(t *testing.T) {
fmt.Fprint(w, `{"data":{"id":1,"notes":"updated notes"}}`)
})

task, err := client.CreateTask(ctx, map[string]string{
task, err := client.CreateTask(context.Background(), map[string]string{
"key1": "value1",
"key2": "value2",
}, nil)
Expand Down

0 comments on commit 84ac3b0

Please sign in to comment.