Example #1
0
func ShouldList(t testing.TB, s store.Store, after string, limit int, expect []string) {
	got, err := s.List(after, limit, nil)
	if err != nil {
		t.Errorf("Unexpected error from List(%#v, %v): %v", after, limit, err)
		return
	}

	if !((len(got) == 0 && len(expect) == 0) ||
		reflect.DeepEqual(got, expect)) {

		t.Errorf("List(%#v, %v) = %#v, but wanted %#v",
			after, limit, got, expect)
	}
}
Example #2
0
func ShouldListCount(t testing.TB, s store.Store, count int) {
	actualCount := 0

	from := ""
	for {
		list, err := s.List(from, 100, nil)
		if err != nil {
			t.Errorf("Couldn't List(%#v, 100): %v", from, err)
			return
		}

		actualCount += len(list)
		if len(list) < 100 {
			break
		}
	}

	if actualCount != count {
		t.Errorf("Full list returned %v elements but wanted %v", actualCount, count)
	}
}