Skip to content

Commit 7ba8e54

Browse files
author
Mengqi Yu
committed
temp builder tests
1 parent ab11fc3 commit 7ba8e54

File tree

2 files changed

+203
-0
lines changed

2 files changed

+203
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 builder
18+
19+
//import (
20+
// "testing"
21+
//
22+
// . "github.com/onsi/ginkgo"
23+
// . "github.com/onsi/gomega"
24+
//
25+
// "sigs.k8s.io/controller-runtime/pkg/envtest"
26+
// logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
27+
//)
28+
//
29+
//func TestSource(t *testing.T) {
30+
// RegisterFailHandler(Fail)
31+
// RunSpecsWithDefaultAndCustomReporters(t, "application Suite", []Reporter{envtest.NewlineReporter{}})
32+
//}
33+
//
34+
//var testenv *envtest.Environment
35+
//
36+
//var _ = BeforeSuite(func(done Done) {
37+
// logf.SetLogger(logf.ZapLoggerTo(GinkgoWriter, true))
38+
//
39+
// close(done)
40+
//}, 60)
41+
//
42+
//var _ = AfterSuite(func() {
43+
// testenv.Stop()
44+
//})
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
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 builder
18+
19+
//import (
20+
// "context"
21+
// "errors"
22+
//
23+
// . "github.com/onsi/ginkgo"
24+
// . "github.com/onsi/gomega"
25+
//
26+
// admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1"
27+
// corev1 "k8s.io/api/core/v1"
28+
// "k8s.io/apimachinery/pkg/api/meta"
29+
// "k8s.io/apimachinery/pkg/runtime"
30+
// "k8s.io/apimachinery/pkg/runtime/schema"
31+
// "k8s.io/client-go/kubernetes/scheme"
32+
// "k8s.io/client-go/rest"
33+
// "k8s.io/client-go/tools/record"
34+
// "sigs.k8s.io/controller-runtime/pkg/cache"
35+
// "sigs.k8s.io/controller-runtime/pkg/client"
36+
// "sigs.k8s.io/controller-runtime/pkg/manager"
37+
// "sigs.k8s.io/controller-runtime/pkg/webhook/admission"
38+
// webhooktypes "sigs.k8s.io/controller-runtime/pkg/webhook/types"
39+
//)
40+
//
41+
//var versionErr = errors.New("not a version")
42+
//
43+
//func versionErrIfFalse(b bool) error {
44+
// if b {
45+
// return nil
46+
// }
47+
// return versionErr
48+
//}
49+
//
50+
//var mapper = meta.NewDefaultRESTMapper([]schema.GroupVersion{{Version: "v1"}}, func(version schema.GroupVersion) (*meta.VersionInterfaces, error) {
51+
// return &meta.VersionInterfaces{
52+
// ObjectConvertor: scheme.Scheme,
53+
// MetadataAccessor: meta.NewAccessor(),
54+
// }, versionErrIfFalse(version == schema.GroupVersion{Version: "v1"})
55+
//})
56+
//
57+
//var _ = Describe("admission webhook", func() {
58+
// var handler admission.Handler
59+
// var mgr manager.Manager
60+
//
61+
// BeforeEach(func() {
62+
// handler = admission.HandlerFunc(func(context.Context, admission.Request) admission.Response { return admission.Response{} })
63+
// mgr = &fakeManager{
64+
// scheme: scheme.Scheme,
65+
// mapper: meta.NewDefaultRESTMapper([]schema.GroupVersion{{Version: "v1"}}, nil),
66+
// }
67+
//
68+
// })
69+
//
70+
// Describe("New", func() {
71+
// It("should return success if given valid inputs", func() {
72+
// w, err := NewWebhookBuilder().
73+
// Name("testwebhook.k8s.io").
74+
// Type(webhooktypes.WebhookTypeMutating).
75+
// Path("/test-path").
76+
// Operations(admissionregistrationv1beta1.Create, admissionregistrationv1beta1.Update).
77+
// WithManager(mgr).
78+
// ForType(&corev1.Pod{}).
79+
// Build(handler)
80+
// Expect(err).NotTo(HaveOccurred())
81+
// Expect(w).NotTo(BeNil())
82+
// })
83+
//
84+
// //It("should return an error if the Config is invalid", func() {
85+
// // w, err := NewWebhookBuilder().
86+
// // Name("testwebhook.k8s.io").
87+
// // Type(webhooktypes.WebhookTypeMutating).
88+
// // Path("/test-path").
89+
// // Operations(admissionregistrationv1beta1.Create, admissionregistrationv1beta1.Update).
90+
// // WithManager(mgr).
91+
// // ForType(&appsv1.Deployment{}).
92+
// // Build(handler)
93+
// // Expect(err).To(HaveOccurred())
94+
// // Expect(err.Error()).To(ContainSubstring("expected error"))
95+
// // Expect(w).To(BeNil())
96+
// //})
97+
//
98+
// })
99+
//
100+
//})
101+
//
102+
//var _ runtime.Object = &fakeType{}
103+
//
104+
//type fakeType struct{}
105+
//
106+
//func (*fakeType) GetObjectKind() schema.ObjectKind { return nil }
107+
//func (*fakeType) DeepCopyObject() runtime.Object { return nil }
108+
//
109+
//var _ manager.Manager = &fakeManager{}
110+
//
111+
//type fakeManager struct {
112+
// client client.Client
113+
// scheme *runtime.Scheme
114+
// mapper meta.RESTMapper
115+
//}
116+
//
117+
//func (fm *fakeManager) Add(r manager.Runnable) error {
118+
// return nil
119+
//}
120+
//
121+
//func (fm *fakeManager) SetFields(i interface{}) error {
122+
// return nil
123+
//}
124+
//
125+
//func (fm *fakeManager) GetConfig() *rest.Config {
126+
// return nil
127+
//}
128+
//
129+
//func (fm *fakeManager) GetClient() client.Client {
130+
// return fm.client
131+
//}
132+
//
133+
//func (fm *fakeManager) GetScheme() *runtime.Scheme {
134+
// return fm.scheme
135+
//}
136+
//
137+
//func (fm *fakeManager) GetAdmissionDecoder() admission.Decoder {
138+
// return nil
139+
//}
140+
//
141+
//func (fm *fakeManager) GetFieldIndexer() client.FieldIndexer {
142+
// return nil
143+
//}
144+
//
145+
//func (fm *fakeManager) GetCache() cache.Cache {
146+
// return nil
147+
//}
148+
//
149+
//func (fm *fakeManager) GetRecorder(name string) record.EventRecorder {
150+
// return nil
151+
//}
152+
//
153+
//func (fm *fakeManager) GetRESTMapper() meta.RESTMapper {
154+
// return fm.mapper
155+
//}
156+
//
157+
//func (fm *fakeManager) Start(stop <-chan struct{}) error {
158+
// return nil
159+
//}

0 commit comments

Comments
 (0)