Skip to content
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

Merged
merged 1 commit into from
Jul 25, 2018

Conversation

ashetty1
Copy link
Contributor

@ashetty1 ashetty1 commented May 28, 2018

Adds test for NewAppS2I, GetImageStreams func in pkg/occlient/occlient.go

@surajnarwade surajnarwade added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label May 29, 2018
@ashetty1 ashetty1 force-pushed the is_test branch 2 times, most recently from 3d3eaab to b4030b8 Compare May 30, 2018 09:26
@ashetty1 ashetty1 changed the title [WIP] Imagestream unit tests Imagestream unit tests May 30, 2018
@ashetty1 ashetty1 force-pushed the is_test branch 2 times, most recently from d386f46 to 1d633b1 Compare May 30, 2018 12:13
@ashetty1
Copy link
Contributor Author

Up for the first review @cdrage @kadel @syamgk

)

// fakeImageStream gets imagestream for the reactor
func fakeImageStream() *imagev1.ImageStream {

This comment was marked as resolved.

@ashetty1 ashetty1 changed the title Imagestream unit tests Imagestream and Buildconfigs unit tests Jun 5, 2018
@surajnarwade surajnarwade removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jun 11, 2018
Copy link
Member

@cdrage cdrage left a 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!

Copy link
Contributor

@surajnarwade surajnarwade left a 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 :)

@syamgk
Copy link
Member

syamgk commented Jun 14, 2018

LGTM

tt.args.labels,
tt.args.annotations)

if (err != nil) != tt.wantErr {
Copy link
Member

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.


if (err != nil) != tt.wantErr {
t.Errorf("NewAppS2I() error = %#v, wantErr %#v", err, tt.wantErr)
return
Copy link
Member

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.

{
name: "testing a valid imagestream",
args: args{
namespace: "testing",
Copy link
Member

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

args args
wantErr bool
}{
{
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

@kadel kadel Jul 11, 2018

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
    ...
    ...

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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
}{
{
Copy link
Member

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

wantGit *buildv1.BuildSource
wantErr bool
}{
{
Copy link
Member

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: ""

"app.kubernetes.io/url": "https://github.com/openshift/ruby",
"app.kubernetes.io/component-source-type": "git",
},
wantGit: &buildv1.BuildSource{
Copy link
Member

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

@ashetty1 ashetty1 added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. labels Jun 19, 2018
@ashetty1 ashetty1 force-pushed the is_test branch 2 times, most recently from 59a7e87 to 6db3649 Compare July 3, 2018 08:04
@ashetty1 ashetty1 removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. labels Jul 4, 2018
@ashetty1 ashetty1 force-pushed the is_test branch 3 times, most recently from 2c58bf9 to 39b7fad Compare July 10, 2018 12:27
}

if err == nil {
createdIS := fkclientset.ImageClientset.Actions()[2].(ktesting.CreateAction).GetObject().(*imagev1.ImageStream)
Copy link
Member

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?

@ashetty1
Copy link
Contributor Author

The tests are failing because our functions don't have checks for empty strings. @kadel, kindly check if this looks okay

…ons in pkg/occlient/occlient.go:

Imagestream functions covered: NewAppS2I(), GetImageStreams()
Buildconfig functions covered: StartBuild()
Watch functions covered: WaitForBuildToFinish(), WaitAndGetPod()
project funtions: CreateNewProject()
@ashetty1
Copy link
Contributor Author

@cdrage those failing tests have been commented now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants