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

Unit test add odo-file-index.json to gitignore file #2441

Conversation

prietyc123
Copy link
Contributor

/kind test

What does does this PR do / why we need it:

Add unit test for odo-file-index.json into gitignore file

Which issue(s) this PR fixes:

Fixes #2404

How to test changes / Special notes to the reviewer:
make test

@prietyc123
Copy link
Contributor Author

/retest

@cdrage
Copy link
Member

cdrage commented Dec 10, 2019

@prietyc123 Needs rebase. Is this ready for review?

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Dec 10, 2019
@prietyc123 prietyc123 force-pushed the UnitTestAddOdoFileIndexJsonToGitignoreFile branch from ceec79b to c1350f7 Compare December 12, 2019 13:31
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Dec 12, 2019
@prietyc123
Copy link
Contributor Author

@prietyc123 Needs rebase. Is this ready for review?

Rebase is done. Yes its ready for review.

Copy link
Member

@dharmit dharmit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested minor change and asked a question where I'm confused.

pkg/util/file_indexer_test.go Show resolved Hide resolved

func mockDirectoryInfo(create bool, contextDir string, fs filesystem.Filesystem) error {

if !create {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused. This condition will be satisfied when create is set to false. So when it's false, we're creating the file/directory and when it's true, we're not doing anything of the sort. This is by design, right?

Just trying to affirm my understanding. Correct me if I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct @dharmit

In the test case where .gitignore directory does not exist, create will be set to true as we don't want that directory to exist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels counter-intuitive to me. In the scenario that you explained, why not have create set to false since we already have what we need? Since you have used the word "directory" twice, aren't we talking about .gitignore file here? I'm feeling lost here. 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"directory" is the kind of context directory you can say where the component will get created. That directory we need to pass to the functions.

Again in second unit test https://github.com/openshift/odo/pull/2441/files#diff-0292f6b604e75b79cef052987afa7fb5R72 we should be having .gitignore file as already checked from https://github.com/openshift/odo/pull/2441/files#diff-0292f6b604e75b79cef052987afa7fb5R11

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the earlier comment, you wrote:

In the test case where .gitignore directory does not exist

so I thought you're talking about a directory called .gitinore. Hence the question.

I'm still confused as to why we're creating a directory when create bool is false. 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the earlier comment, you wrote:

In the test case where .gitignore directory does not exist

so I thought you're talking about a directory called .gitinore. Hence the question.

I'm still confused as to why we're creating a directory when create bool is false. 😕

Because whatever false directory we are creating will get created in RAM and once that unit test is complete it will delete the directory and everything.

As for https://github.com/openshift/odo/pull/2441/files#diff-0292f6b604e75b79cef052987afa7fb5R72 this unit test .gitignore file should be there to add odo-file-index into .gitignore.

Hence create bool is set to false, so that we can have .gitignore file there in the directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I thought you're talking about a directory called .gitinore. Hence the question.

There are two different unit test, one for checking .gitignore exists or not. If not then create one. Second is to add odo-file-index.json into .gitignore.

If we can link these two unit test then create bool will be set to true. So is there any way we can do that as I am not aware of that. Please do suggest if there is any way to return .gitignore path from the first unit test I mentioned above. If not then we have have to create .gitignore directory as we are using fake filesystem with afero.

pkg/util/file_indexer_test.go Show resolved Hide resolved
@kadel
Copy link
Member

kadel commented Dec 16, 2019

@girishramnani is probably the right person to review changes in fakefs pkg
/cc @girishramnani

@girishramnani
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: girishramnani

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Dec 17, 2019
@cdrage
Copy link
Member

cdrage commented Dec 20, 2019

/lgtm

Looks good to me!

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Dec 20, 2019
@openshift-merge-robot openshift-merge-robot merged commit 100e1ad into redhat-developer:master Dec 20, 2019
@rm3l rm3l added the estimated-size/L (20-40) Rough sizing for Epics. About 2 sprints of work for a person. label Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. estimated-size/L (20-40) Rough sizing for Epics. About 2 sprints of work for a person. lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit Test for Adding odo file index json to gitignore file
8 participants