mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Fix naming in storage test setup
This commit is contained in:
parent
c519bc02e8
commit
1bc95675b1
@ -482,7 +482,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
t.Errorf("Unexpected error: %v", err)
|
t.Errorf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
continueRV, _ := strconv.Atoi(list.ResourceVersion)
|
continueRV, _ := strconv.Atoi(list.ResourceVersion)
|
||||||
secondContinuation, err := storage.EncodeContinue("/two-level/2", "/two-level/", int64(continueRV))
|
secondContinuation, err := storage.EncodeContinue("/two-level/foo", "/two-level/", int64(continueRV))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -533,20 +533,20 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List on existing key",
|
name: "test List on existing key",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
expectedOut: []*example.Pod{preset[0]},
|
expectedOut: []*example.Pod{preset[0]},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List on existing key with resource version set to 0",
|
name: "test List on existing key with resource version set to 0",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
expectedOut: []*example.Pod{preset[0]},
|
expectedOut: []*example.Pod{preset[0]},
|
||||||
rv: "0",
|
rv: "0",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List on existing key with resource version set before first write, match=Exact",
|
name: "test List on existing key with resource version set before first write, match=Exact",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
expectedOut: []*example.Pod{},
|
expectedOut: []*example.Pod{},
|
||||||
rv: initialRV,
|
rv: initialRV,
|
||||||
@ -555,7 +555,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List on existing key with resource version set to 0, match=NotOlderThan",
|
name: "test List on existing key with resource version set to 0, match=NotOlderThan",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
expectedOut: []*example.Pod{preset[0]},
|
expectedOut: []*example.Pod{preset[0]},
|
||||||
rv: "0",
|
rv: "0",
|
||||||
@ -563,7 +563,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List on existing key with resource version set to 0, match=Invalid",
|
name: "test List on existing key with resource version set to 0, match=Invalid",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
rv: "0",
|
rv: "0",
|
||||||
rvMatch: "Invalid",
|
rvMatch: "Invalid",
|
||||||
@ -571,7 +571,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List on existing key with resource version set before first write, match=NotOlderThan",
|
name: "test List on existing key with resource version set before first write, match=NotOlderThan",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
expectedOut: []*example.Pod{preset[0]},
|
expectedOut: []*example.Pod{preset[0]},
|
||||||
rv: initialRV,
|
rv: initialRV,
|
||||||
@ -579,7 +579,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List on existing key with resource version set before first write, match=Invalid",
|
name: "test List on existing key with resource version set before first write, match=Invalid",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
rv: initialRV,
|
rv: initialRV,
|
||||||
rvMatch: "Invalid",
|
rvMatch: "Invalid",
|
||||||
@ -587,14 +587,14 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List on existing key with resource version set to current resource version",
|
name: "test List on existing key with resource version set to current resource version",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
expectedOut: []*example.Pod{preset[0]},
|
expectedOut: []*example.Pod{preset[0]},
|
||||||
rv: list.ResourceVersion,
|
rv: list.ResourceVersion,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List on existing key with resource version set to current resource version, match=Exact",
|
name: "test List on existing key with resource version set to current resource version, match=Exact",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
expectedOut: []*example.Pod{preset[0]},
|
expectedOut: []*example.Pod{preset[0]},
|
||||||
rv: list.ResourceVersion,
|
rv: list.ResourceVersion,
|
||||||
@ -603,7 +603,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List on existing key with resource version set to current resource version, match=NotOlderThan",
|
name: "test List on existing key with resource version set to current resource version, match=NotOlderThan",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
expectedOut: []*example.Pod{preset[0]},
|
expectedOut: []*example.Pod{preset[0]},
|
||||||
rv: list.ResourceVersion,
|
rv: list.ResourceVersion,
|
||||||
@ -617,16 +617,16 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List with pod name matching",
|
name: "test List with pod name matching",
|
||||||
prefix: "/one-level/",
|
prefix: "/first/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Field: fields.ParseSelectorOrDie("metadata.name!=foo"),
|
Field: fields.ParseSelectorOrDie("metadata.name!=bar"),
|
||||||
},
|
},
|
||||||
expectedOut: nil,
|
expectedOut: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List with limit",
|
name: "test List with limit",
|
||||||
prefix: "/two-level/",
|
prefix: "/second/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Field: fields.Everything(),
|
Field: fields.Everything(),
|
||||||
@ -638,7 +638,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List with limit at current resource version",
|
name: "test List with limit at current resource version",
|
||||||
prefix: "/two-level/",
|
prefix: "/second/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Field: fields.Everything(),
|
Field: fields.Everything(),
|
||||||
@ -652,7 +652,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List with limit at current resource version and match=Exact",
|
name: "test List with limit at current resource version and match=Exact",
|
||||||
prefix: "/two-level/",
|
prefix: "/second/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Field: fields.Everything(),
|
Field: fields.Everything(),
|
||||||
@ -667,7 +667,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List with limit at resource version 0",
|
name: "test List with limit at resource version 0",
|
||||||
prefix: "/two-level/",
|
prefix: "/second/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Field: fields.Everything(),
|
Field: fields.Everything(),
|
||||||
@ -681,7 +681,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List with limit at resource version 0 match=NotOlderThan",
|
name: "test List with limit at resource version 0 match=NotOlderThan",
|
||||||
prefix: "/two-level/",
|
prefix: "/second/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Field: fields.Everything(),
|
Field: fields.Everything(),
|
||||||
@ -696,7 +696,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List with limit at resource version before first write and match=Exact",
|
name: "test List with limit at resource version before first write and match=Exact",
|
||||||
prefix: "/two-level/",
|
prefix: "/second/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Field: fields.Everything(),
|
Field: fields.Everything(),
|
||||||
@ -710,7 +710,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List with pregenerated continue token",
|
name: "test List with pregenerated continue token",
|
||||||
prefix: "/two-level/",
|
prefix: "/second/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Field: fields.Everything(),
|
Field: fields.Everything(),
|
||||||
@ -721,7 +721,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "ignores resource version 0 for List with pregenerated continue token",
|
name: "ignores resource version 0 for List with pregenerated continue token",
|
||||||
prefix: "/two-level/",
|
prefix: "/second/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Field: fields.Everything(),
|
Field: fields.Everything(),
|
||||||
@ -733,7 +733,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test List with multiple levels of directories and expect flattened result",
|
name: "test List with multiple levels of directories and expect flattened result",
|
||||||
prefix: "/two-level/",
|
prefix: "/second/",
|
||||||
pred: storage.Everything,
|
pred: storage.Everything,
|
||||||
expectedOut: []*example.Pod{preset[1], preset[2]},
|
expectedOut: []*example.Pod{preset[1], preset[2]},
|
||||||
},
|
},
|
||||||
@ -741,7 +741,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
name: "test List with filter returning only one item, ensure only a single page returned",
|
name: "test List with filter returning only one item, ensure only a single page returned",
|
||||||
prefix: "/",
|
prefix: "/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Field: fields.OneTermEqualSelector("metadata.name", "fourth"),
|
Field: fields.OneTermEqualSelector("metadata.name", "barfoo"),
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Limit: 1,
|
Limit: 1,
|
||||||
},
|
},
|
||||||
@ -752,7 +752,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
name: "test List with filter returning only one item, covers the entire list",
|
name: "test List with filter returning only one item, covers the entire list",
|
||||||
prefix: "/",
|
prefix: "/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Field: fields.OneTermEqualSelector("metadata.name", "fourth"),
|
Field: fields.OneTermEqualSelector("metadata.name", "barfoo"),
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Limit: 2,
|
Limit: 2,
|
||||||
},
|
},
|
||||||
@ -763,7 +763,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
name: "test List with filter returning only one item, covers the entire list, with resource version 0",
|
name: "test List with filter returning only one item, covers the entire list, with resource version 0",
|
||||||
prefix: "/",
|
prefix: "/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Field: fields.OneTermEqualSelector("metadata.name", "fourth"),
|
Field: fields.OneTermEqualSelector("metadata.name", "barfoo"),
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Limit: 2,
|
Limit: 2,
|
||||||
},
|
},
|
||||||
@ -775,7 +775,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
name: "test List with filter returning two items, more pages possible",
|
name: "test List with filter returning two items, more pages possible",
|
||||||
prefix: "/",
|
prefix: "/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Field: fields.OneTermEqualSelector("metadata.name", "foo"),
|
Field: fields.OneTermEqualSelector("metadata.name", "bar"),
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Limit: 2,
|
Limit: 2,
|
||||||
},
|
},
|
||||||
@ -786,7 +786,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
name: "filter returns two items split across multiple pages",
|
name: "filter returns two items split across multiple pages",
|
||||||
prefix: "/",
|
prefix: "/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Field: fields.OneTermEqualSelector("metadata.name", "bar"),
|
Field: fields.OneTermEqualSelector("metadata.name", "foo"),
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Limit: 2,
|
Limit: 2,
|
||||||
},
|
},
|
||||||
@ -796,10 +796,10 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
name: "filter returns one item for last page, ends on last item, not full",
|
name: "filter returns one item for last page, ends on last item, not full",
|
||||||
prefix: "/",
|
prefix: "/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Field: fields.OneTermEqualSelector("metadata.name", "bar"),
|
Field: fields.OneTermEqualSelector("metadata.name", "foo"),
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Limit: 2,
|
Limit: 2,
|
||||||
Continue: encodeContinueOrDie("z-level/3", int64(continueRV)),
|
Continue: encodeContinueOrDie("third/barfoo", int64(continueRV)),
|
||||||
},
|
},
|
||||||
expectedOut: []*example.Pod{preset[4]},
|
expectedOut: []*example.Pod{preset[4]},
|
||||||
},
|
},
|
||||||
@ -807,10 +807,10 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
name: "filter returns one item for last page, starts on last item, full",
|
name: "filter returns one item for last page, starts on last item, full",
|
||||||
prefix: "/",
|
prefix: "/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Field: fields.OneTermEqualSelector("metadata.name", "bar"),
|
Field: fields.OneTermEqualSelector("metadata.name", "foo"),
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Limit: 1,
|
Limit: 1,
|
||||||
Continue: encodeContinueOrDie("z-level/3/test-2", int64(continueRV)),
|
Continue: encodeContinueOrDie("third/barfoo", int64(continueRV)),
|
||||||
},
|
},
|
||||||
expectedOut: []*example.Pod{preset[4]},
|
expectedOut: []*example.Pod{preset[4]},
|
||||||
},
|
},
|
||||||
@ -818,10 +818,10 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
name: "filter returns one item for last page, starts on last item, partial page",
|
name: "filter returns one item for last page, starts on last item, partial page",
|
||||||
prefix: "/",
|
prefix: "/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Field: fields.OneTermEqualSelector("metadata.name", "bar"),
|
Field: fields.OneTermEqualSelector("metadata.name", "foo"),
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Limit: 2,
|
Limit: 2,
|
||||||
Continue: encodeContinueOrDie("z-level/3/test-2", int64(continueRV)),
|
Continue: encodeContinueOrDie("third/barfoo", int64(continueRV)),
|
||||||
},
|
},
|
||||||
expectedOut: []*example.Pod{preset[4]},
|
expectedOut: []*example.Pod{preset[4]},
|
||||||
},
|
},
|
||||||
@ -829,7 +829,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
name: "filter returns two items, page size equal to total list size",
|
name: "filter returns two items, page size equal to total list size",
|
||||||
prefix: "/",
|
prefix: "/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Field: fields.OneTermEqualSelector("metadata.name", "bar"),
|
Field: fields.OneTermEqualSelector("metadata.name", "foo"),
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Limit: 5,
|
Limit: 5,
|
||||||
},
|
},
|
||||||
@ -839,7 +839,7 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface) {
|
|||||||
name: "filter returns one item, page size equal to total list size",
|
name: "filter returns one item, page size equal to total list size",
|
||||||
prefix: "/",
|
prefix: "/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Field: fields.OneTermEqualSelector("metadata.name", "fourth"),
|
Field: fields.OneTermEqualSelector("metadata.name", "barfoo"),
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Limit: 5,
|
Limit: 5,
|
||||||
},
|
},
|
||||||
@ -934,7 +934,7 @@ func RunTestListWithoutPaging(ctx context.Context, t *testing.T, store storage.I
|
|||||||
{
|
{
|
||||||
name: "test List with limit when paging disabled",
|
name: "test List with limit when paging disabled",
|
||||||
disablePaging: true,
|
disablePaging: true,
|
||||||
prefix: "/two-level/",
|
prefix: "/second/",
|
||||||
pred: storage.SelectionPredicate{
|
pred: storage.SelectionPredicate{
|
||||||
Label: labels.Everything(),
|
Label: labels.Everything(),
|
||||||
Field: fields.Everything(),
|
Field: fields.Everything(),
|
||||||
@ -986,46 +986,46 @@ func RunTestListWithoutPaging(ctx context.Context, t *testing.T, store storage.I
|
|||||||
func seedMultiLevelData(ctx context.Context, store storage.Interface) (string, []*example.Pod, error) {
|
func seedMultiLevelData(ctx context.Context, store storage.Interface) (string, []*example.Pod, error) {
|
||||||
// Setup storage with the following structure:
|
// Setup storage with the following structure:
|
||||||
// /
|
// /
|
||||||
// - one-level/
|
// - first/
|
||||||
// | - test
|
// | - bar
|
||||||
// |
|
// |
|
||||||
// - two-level/
|
// - second/
|
||||||
// | - 1/
|
// | - bar
|
||||||
// | | - test
|
// | - foo
|
||||||
// | |
|
|
||||||
// | - 2/
|
|
||||||
// | - test
|
|
||||||
// |
|
// |
|
||||||
// - z-level/
|
// - third/
|
||||||
// - 3/
|
// | - barfoo
|
||||||
// | - test
|
// | - foo
|
||||||
// |
|
barFirst := &example.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: "first", Name: "bar"}}
|
||||||
// - 3/
|
barSecond := &example.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: "second", Name: "bar"}}
|
||||||
// - test-2
|
fooSecond := &example.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: "second", Name: "foo"}}
|
||||||
|
barfooThird := &example.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: "third", Name: "barfoo"}}
|
||||||
|
fooThird := &example.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: "third", Name: "foo"}}
|
||||||
|
|
||||||
preset := []struct {
|
preset := []struct {
|
||||||
key string
|
key string
|
||||||
obj *example.Pod
|
obj *example.Pod
|
||||||
storedObj *example.Pod
|
storedObj *example.Pod
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
key: "/one-level/test",
|
key: computePodKey(barFirst),
|
||||||
obj: &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}},
|
obj: barFirst,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "/two-level/1/test",
|
key: computePodKey(barSecond),
|
||||||
obj: &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}},
|
obj: barSecond,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "/two-level/2/test",
|
key: computePodKey(fooSecond),
|
||||||
obj: &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "bar"}},
|
obj: fooSecond,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "/z-level/3/test",
|
key: computePodKey(barfooThird),
|
||||||
obj: &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "fourth"}},
|
obj: barfooThird,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "/z-level/3/test-2",
|
key: computePodKey(fooThird),
|
||||||
obj: &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "bar"}},
|
obj: fooThird,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +77,15 @@ func DeepEqualSafePodSpec() example.PodSpec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func computePodKey(obj *example.Pod) string {
|
||||||
|
return fmt.Sprintf("/%s/%s", obj.Namespace, obj.Name)
|
||||||
|
}
|
||||||
|
|
||||||
// testPropagateStore helps propagates store with objects, automates key generation, and returns
|
// testPropagateStore helps propagates store with objects, automates key generation, and returns
|
||||||
// keys and stored objects.
|
// keys and stored objects.
|
||||||
func testPropagateStore(ctx context.Context, t *testing.T, store storage.Interface, obj *example.Pod) (string, *example.Pod) {
|
func testPropagateStore(ctx context.Context, t *testing.T, store storage.Interface, obj *example.Pod) (string, *example.Pod) {
|
||||||
// Setup store with a key and grab the output for returning.
|
// Setup store with a key and grab the output for returning.
|
||||||
key := fmt.Sprintf("/%s/%s", obj.Namespace, obj.Name)
|
key := computePodKey(obj)
|
||||||
|
|
||||||
// Setup store with the specified key and grab the output for returning.
|
// Setup store with the specified key and grab the output for returning.
|
||||||
err := store.Delete(ctx, key, &example.Pod{}, nil, storage.ValidateAllObjectFunc, nil)
|
err := store.Delete(ctx, key, &example.Pod{}, nil, storage.ValidateAllObjectFunc, nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user