-
Notifications
You must be signed in to change notification settings - Fork 243
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
Imagestream and Buildconfigs unit tests #478
Conversation
3d3eaab
to
b4030b8
Compare
d386f46
to
1d633b1
Compare
pkg/occlient/occlient_test.go
Outdated
) | ||
|
||
// fakeImageStream gets imagestream for the reactor | ||
func fakeImageStream() *imagev1.ImageStream { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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 a ton of tests being added!
Many thanks. This LGTM!
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.
Tested this PR, works && LGTM :)
LGTM |
tt.args.labels, | ||
tt.args.annotations) | ||
|
||
if (err != nil) != tt.wantErr { |
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.
It should do more than just check if the error was returned.
We are already doing this in the code.
The test should verify that odo component or openshift objects were created.
pkg/occlient/occlient_test.go
Outdated
|
||
if (err != nil) != tt.wantErr { | ||
t.Errorf("NewAppS2I() error = %#v, wantErr %#v", err, tt.wantErr) | ||
return |
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.
return
shouldn't be there, otherwise, it won't continue to the next test case.
pkg/occlient/occlient_test.go
Outdated
{ | ||
name: "testing a valid imagestream", | ||
args: args{ | ||
namespace: "testing", |
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.
testing
namespace is passed, but in want
namespace is openshift
that looks strange
pkg/occlient/occlient_test.go
Outdated
args args | ||
wantErr bool | ||
}{ | ||
{ |
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.
there should be more than one testcase
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.
Hmm, it is getting imagestreams. Any suggestion on what the second test could be?
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.
-
tests should also verify that error is returned when it should be returned
- builderImage that doesn't exist
- empty builderImage
-
verify that if empty
gitURL
is passed that BuildConfig has BuildSourceBinary -
verify that if
gitURL
is not empty than BuildConfig has GitBuildSource
...
...
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.
@kadel sure! Was wondering if empty gitUrl
or builderImage
would be a valid usecase for us. Thanks for the clarification. Will add that to this as well as other functions.
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.
One important test that I think we are still missing is non-empty builderImage that doesn't' exist.
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.
@kadel how to do that? You mean not have a valid response through reactor?
want []imagev1.ImageStream | ||
wantErr bool | ||
}{ | ||
{ |
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.
there should be more than one test case
pkg/occlient/occlient_test.go
Outdated
wantGit *buildv1.BuildSource | ||
wantErr bool | ||
}{ | ||
{ |
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.
there should be more test cases, for example one with gitUrl: ""
pkg/occlient/occlient_test.go
Outdated
"app.kubernetes.io/url": "https://github.com/openshift/ruby", | ||
"app.kubernetes.io/component-source-type": "git", | ||
}, | ||
wantGit: &buildv1.BuildSource{ |
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.
wantBuildSource
might be a better name
59a7e87
to
6db3649
Compare
2c58bf9
to
39b7fad
Compare
pkg/occlient/occlient_test.go
Outdated
} | ||
|
||
if err == nil { | ||
createdIS := fkclientset.ImageClientset.Actions()[2].(ktesting.CreateAction).GetObject().(*imagev1.ImageStream) |
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.
why are we checking just 3rd
action? What if the order in which ImageStream is created changes?
The tests are failing because our functions don't have checks for empty strings. @kadel, kindly check if this looks okay |
b8d3cf6
to
ba71fee
Compare
…ons in pkg/occlient/occlient.go: Imagestream functions covered: NewAppS2I(), GetImageStreams() Buildconfig functions covered: StartBuild() Watch functions covered: WaitForBuildToFinish(), WaitAndGetPod() project funtions: CreateNewProject()
@cdrage those failing tests have been commented now. |
Adds test for
NewAppS2I
,GetImageStreams
func inpkg/occlient/occlient.go