Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure we have failing tests refs #66 for pagesize, paging #70

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ func ListObjsAndFolders(t TestingT, store cloudstorage.Store) {

createObjects(names)

// Test that we can get the full list of 15 objects
q := cloudstorage.NewQuery("list-test/")
q.PageSize = 500
q.Sorted()
Expand All @@ -509,6 +510,7 @@ func ListObjsAndFolders(t TestingT, store cloudstorage.Store) {
assert.Equal(t, 15, len(objs), "incorrect list len. wanted 15 got %d", len(objs))
iter.Close()

// Now test the response from iter
iter, _ = store.Objects(context.Background(), q)
objr, err := cloudstorage.ObjectResponseFromIter(iter)
assert.Equal(t, nil, err)
Expand All @@ -521,6 +523,21 @@ func ListObjsAndFolders(t TestingT, store cloudstorage.Store) {
assert.Equal(t, nil, err)
assert.Equal(t, 15, len(objResp.Objects), "incorrect list len. wanted 15 got %d", len(objResp.Objects))

// Now we are going to test page-sizing, ie set page size below known list
q = cloudstorage.NewQuery("list-test/")
q.PageSize = 3
iter, _ = store.Objects(context.Background(), q)
objr, err = cloudstorage.ObjectResponseFromIter(iter)
// Even though page size=3, we actually want 15 because it is going
// to page through multiple pages.
assert.Equal(t, nil, err)
assert.Equal(t, 15, len(objr.Objects), "incorrect list len. wanted 15 got %d", len(objr.Objects))
// Now ensure we can get only 3
objr, err = store.List(context.Background(), q)
assert.Equal(t, nil, err)
assert.Equal(t, 3, len(objr.Objects), "incorrect list len. wanted 3 got %d", len(objr.Objects))
assert.NotEqual(t, "", objr.NextMarker)

// Now we are going to re-run this test using an Object Iterator
// that uses store.List() instead of store.Objects()
q = cloudstorage.NewQuery("list-test/")
Expand Down