-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtestutils_test.go
More file actions
43 lines (32 loc) · 854 Bytes
/
testutils_test.go
File metadata and controls
43 lines (32 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package kcache
import (
"context"
"testing"
logutil "github.com/boz/go-logutil"
"github.com/boz/kcache/filter"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func testGenPod(ns, name, vsn string) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Namespace: ns,
Name: name,
ResourceVersion: vsn,
},
}
}
func testGenEvent(et EventType, ns, name, vsn string) Event {
return NewEvent(et, testGenPod(ns, name, vsn))
}
func testNewSubscription(t *testing.T, log logutil.Log, f filter.Filter) (subscription, cache, chan struct{}) {
ctx, cancel := context.WithCancel(context.Background())
readych := make(chan struct{})
cache := newCache(ctx, log, nil, f)
sub := newSubscription(log, nil, readych, cache)
go func() {
<-sub.Done()
cancel()
}()
return sub, cache, readych
}