func TestList(t *testing.T) { th.SetupHTTP() defer th.TeardownHTTP() os.MockListResponse(t) count := 0 err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) { count++ actual, err := ExtractVolumes(page) if err != nil { t.Errorf("Failed to extract volumes: %v", err) return false, err } expected := []Volume{ Volume{ ID: "289da7f8-6440-407c-9fb4-7db01ec49164", Name: "vol-001", }, Volume{ ID: "96c3bda7-c82a-4f50-be73-ca7621794835", Name: "vol-002", }, } th.CheckDeepEquals(t, expected, actual) return true, nil }) th.AssertEquals(t, 1, count) th.AssertNoErr(t, err) }
func TestListAll(t *testing.T) { th.SetupHTTP() defer th.TeardownHTTP() fixtures.MockListResponse(t) allPages, err := List(client.ServiceClient(), &ListOpts{}).AllPages() th.AssertNoErr(t, err) actual, err := ExtractVolumes(allPages) th.AssertNoErr(t, err) expected := []Volume{ Volume{ ID: "289da7f8-6440-407c-9fb4-7db01ec49164", Name: "vol-001", }, Volume{ ID: "96c3bda7-c82a-4f50-be73-ca7621794835", Name: "vol-002", }, } th.CheckDeepEquals(t, expected, actual) }