-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add runtime test #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add runtime test #34
Conversation
@fanzhangio please run |
|
||
var _ = BeforeSuite(func(done Done) { | ||
|
||
testenv = &test.Environment{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is expensive to bring up just to get a* rest.Config that isn't used for anything.
Instead just create a dummy config with some values filled in.
@pwittrock I simplified the test suites, and removed the redundant codes. |
pkg/runtime/inject/inject_test.go
Outdated
It("should set informers", func() { | ||
instance := testSource{ | ||
cache: func(c cache.Cache) error { | ||
if c != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should validate that the injected argument is the same as the one you provided.
pkg/runtime/inject/inject_test.go
Outdated
if s.cache != nil { | ||
return s.cache(c) | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably Fail("unexpected call")
or something right?
pkg/runtime/inject/inject_test.go
Outdated
res, err := CacheInto(&informertest.FakeInformers{}, instance) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(res).To(Equal(true)) | ||
res, err = CacheInto(&informertest.FakeInformers{}, neg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it clear what htis is testing with a By("returning false if the type doesn't implement inject.Cache")
pkg/runtime/inject/inject_test.go
Outdated
Expect(res).To(Equal(true)) | ||
res, err = CacheInto(&informertest.FakeInformers{}, neg) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(res).To(Equal(false)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check an error case for when an error is returned.
pkg/runtime/signals/signal_test.go
Outdated
It("should close stop channel by signal", func() { | ||
|
||
stop := SetupSignalHandler() | ||
p, err := os.FindProcess(syscall.Getpid()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cool, but the handlers aren't setup right it might doing something weird. It also changes the signal handler for the whole process.
How about
- write a small program and exec it
- mock out the
signal.Notify
andos.Exit
calls as functions that we re-assign.
@fanzhangio just did another pass. ptal |
@fanzhangio FYI, you'll have to do a small rebase with the package name changes. |
Needs to run |
Add runtime test
"kubebuilder create config" not "installer containers"
issue #16