Skip to content

Commit 9d36fb0

Browse files
author
fanzhangio
committed
Add runtime test for inject, log and signal
1 parent 8bdb185 commit 9d36fb0

File tree

32 files changed

+5852
-14
lines changed

32 files changed

+5852
-14
lines changed

Gopkg.lock

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cache/informertest/fake_cache.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ func (c *FakeInformers) GetInformerForKind(gvk schema.GroupVersionKind) (toolsca
4343
if c.Scheme == nil {
4444
c.Scheme = scheme.Scheme
4545
}
46-
obj, _ := c.Scheme.New(gvk)
46+
obj, err := c.Scheme.New(gvk)
47+
if err != nil {
48+
return nil, err
49+
}
4750
return c.informerFor(gvk, obj)
4851
}
4952

@@ -52,7 +55,10 @@ func (c *FakeInformers) FakeInformerForKind(gvk schema.GroupVersionKind) (*contr
5255
if c.Scheme == nil {
5356
c.Scheme = scheme.Scheme
5457
}
55-
obj, _ := c.Scheme.New(gvk)
58+
obj, err := c.Scheme.New(gvk)
59+
if err != nil {
60+
return nil, err
61+
}
5662
i, err := c.informerFor(gvk, obj)
5763
if err != nil {
5864
return nil, err
@@ -65,7 +71,10 @@ func (c *FakeInformers) GetInformer(obj runtime.Object) (toolscache.SharedIndexI
6571
if c.Scheme == nil {
6672
c.Scheme = scheme.Scheme
6773
}
68-
gvks, _, _ := c.Scheme.ObjectKinds(obj)
74+
gvks, _, err := c.Scheme.ObjectKinds(obj)
75+
if err != nil {
76+
return nil, err
77+
}
6978
gvk := gvks[0]
7079
return c.informerFor(gvk, obj)
7180
}
@@ -83,7 +92,10 @@ func (c *FakeInformers) FakeInformerFor(obj runtime.Object) (*controllertest.Fak
8392
if c.Scheme == nil {
8493
c.Scheme = scheme.Scheme
8594
}
86-
gvks, _, _ := c.Scheme.ObjectKinds(obj)
95+
gvks, _, err := c.Scheme.ObjectKinds(obj)
96+
if err != nil {
97+
return nil, err
98+
}
8799
gvk := gvks[0]
88100
i, err := c.informerFor(gvk, obj)
89101
if err != nil {

pkg/manager/testutil.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ limitations under the License.
1616

1717
package manager
1818

19-
//
20-
//func SetCacheForTest(options *Options, c func(config *rest.Config, opts cache.Options) (cache.Cache, error)) {
21-
// options.newCache = c
22-
//}
23-
//
24-
//func SetClientForTest(options *Options, c func(config *rest.Config, options client.Options) (client.Client, error)) {
25-
// options.newClient = c
26-
//}
19+
// func SetCacheForTest(options *Options, c func(config *rest.Config, opts cache.Options) (cache.Cache, error)) {
20+
// options.newCache = c
21+
// }
22+
23+
// func SetClientForTest(options *Options, c func(config *rest.Config, options client.Options) (client.Client, error)) {
24+
// options.newClient = c
25+
// }
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package inject
18+
19+
import (
20+
"testing"
21+
22+
. "github.com/onsi/ginkgo"
23+
. "github.com/onsi/gomega"
24+
"sigs.k8s.io/controller-runtime/pkg/test"
25+
)
26+
27+
func TestSource(t *testing.T) {
28+
RegisterFailHandler(Fail)
29+
RunSpecsWithDefaultAndCustomReporters(t, "Runtime Injection Suite", []Reporter{test.NewlineReporter{}})
30+
}

0 commit comments

Comments
 (0)