|
|
|
|
@ -183,6 +183,16 @@ func TestService_List(t *testing.T) {
|
|
|
|
|
_, err = target.ListPage(ctx, []byte("some hash"), 1, filterFunc, tok, nil)
|
|
|
|
|
require.ErrorContains(t, err, "missing repo")
|
|
|
|
|
})
|
|
|
|
|
t.Run("wrong token resource type", func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
filterFunc := func(_ context.Context, t target.Target) (bool, error) {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Session, []byte("some hash"), "some-id", fiveDaysAgo)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = target.ListPage(ctx, []byte("some hash"), 1, filterFunc, tok, repo)
|
|
|
|
|
require.ErrorContains(t, err, "token did not have a target resource type")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
t.Run("ListRefresh validation", func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
@ -251,6 +261,16 @@ func TestService_List(t *testing.T) {
|
|
|
|
|
_, err = target.ListRefresh(ctx, []byte("some hash"), 1, filterFunc, tok, nil)
|
|
|
|
|
require.ErrorContains(t, err, "missing repo")
|
|
|
|
|
})
|
|
|
|
|
t.Run("wrong token resource type", func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
filterFunc := func(_ context.Context, t target.Target) (bool, error) {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Session, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = target.ListRefresh(ctx, []byte("some hash"), 1, filterFunc, tok, repo)
|
|
|
|
|
require.ErrorContains(t, err, "token did not have a target resource type")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
t.Run("ListRefreshPage validation", func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
@ -319,6 +339,16 @@ func TestService_List(t *testing.T) {
|
|
|
|
|
_, err = target.ListRefreshPage(ctx, []byte("some hash"), 1, filterFunc, tok, nil)
|
|
|
|
|
require.ErrorContains(t, err, "missing repo")
|
|
|
|
|
})
|
|
|
|
|
t.Run("wrong token resource type", func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
filterFunc := func(_ context.Context, t target.Target) (bool, error) {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Session, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = target.ListRefreshPage(ctx, []byte("some hash"), 1, filterFunc, tok, repo)
|
|
|
|
|
require.ErrorContains(t, err, "token did not have a target resource type")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("simple pagination", func(t *testing.T) {
|
|
|
|
|
|