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

add fetch test from http #145

Merged
merged 5 commits into from
Oct 2, 2020
Merged

Conversation

dylanhitt
Copy link
Member

@dylanhitt dylanhitt commented Sep 1, 2020

Partially implements #109. @SimonBaeumer reading from stdin could come from another PR or I could bundle it in to this one. I think after stdin I may shoot over some prototypes for some possible refactors of test_command.go. It feels a little strange passing testPath, ctx.Filters, and fileName between many different functions - this could also be addressed in #141 as well.

I'll add some test by the end of the week.

Checklist

  • Added unit / integration tests for windows, macOS and Linux?
  • Added a changelog entry in CHANGELOG.md?
  • Updated the documentation (README.md, docs)?
  • Does your change work on Linux, Windows and macOS?

@@ -36,6 +38,10 @@ func TestCommand(testPath string, ctx TestCommandContext) error {
fmt.Println("Starting test against directory: " + testPath + "...")
Copy link
Member

Choose a reason for hiding this comment

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

What happens if ctx.Dir is true and the path is an URL?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm, I believe the error will get caught in testDir, I'll check what the error message is. What error is it would be the same for file as well. I believe I already handled that. Worse case would you be fine with something like The input is not a directory?

Copy link
Member Author

Choose a reason for hiding this comment

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

files, err := ioutil.ReadDir(directory) will respond with

commander (fetch-test-suites-over-http) $ ./commander test --dir https://raw.githubusercontent.com/commander-cli/commander/master/examples/commander.yaml
Starting test against directory: https://raw.githubusercontent.com/commander-cli/commander/master/examples/commander.yaml...

open https://raw.githubusercontent.com/commander-cli/commander/master/examples/commander.yaml: no such file or directory

and

./commander test --dir examples/commander.yaml Starting test against directory: examples/commander.yaml...

Hello
fdopendir: not a directory

I think a better error here would be

commander (fetch-test-suites-over-http) $ ./commander test --dir example/ 
Starting test against directory: example/...

Error: Input is not a directory
commander (fetch-test-suites-over-http) $ ./commander test --dir https://raw.githubusercontent.com/commander-cli/commander/master/examples/commander.yaml
Starting test against directory: https://raw.githubusercontent.com/commander-cli/commander/master/examples/commander.yaml...

Error: Input is not a directory
commander (fetch-test-suites-over-http) $ ./commander test --dir examples/commander.yaml Starting test against directory: examples/commander.yaml...

Error: Input is not a directory
commander (fetch-test-suites-over-http) $ ./commander test --dir -
Starting test against directory: -...

Error: Input is not a directory

Copy link
Member

Choose a reason for hiding this comment

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

That looks good, thank you!

@SimonBaeumer
Copy link
Member

This looks good to me, reading from stdin could be handeld inside the switch statement too.
I would like to use a syntax like echo "..." | commander test -.

@SimonBaeumer
Copy link
Member

Your code looks good to me, looking forward for the tests 👍

@dylanhitt dylanhitt force-pushed the fetch-test-suites-over-http branch from 4bf9895 to f53aa81 Compare September 14, 2020 01:11
@dylanhitt dylanhitt marked this pull request as ready for review September 15, 2020 03:53
@dylanhitt
Copy link
Member Author

dylanhitt commented Sep 15, 2020

Hey @SimonBaeumer, I finished adding tests. I'm currently targeting a file that's already in master so I can demonstrate the integration test. I plan to switch over to remote_http.yaml once that file is in master.

One important note is that I did add a testing dependency - gock, in order to mock the http request. I'll add url support to the docs tomorrow. I would like to have this merged, and implement stdin in a separate PR, mainly just to switch the integration test file over to remote_http.yaml. If you have another suggestion let me know. Second reason is that i've just been short on time.

Best

@SimonBaeumer
Copy link
Member

SimonBaeumer commented Sep 23, 2020

Your pull request looks great!
Just run go mod vendor to add the gock dependecies in git.

Let me know when you are finished, would love to merge this!

@dylanhitt
Copy link
Member Author

Done!

@codeclimate
Copy link

codeclimate bot commented Sep 26, 2020

Code Climate has analyzed commit f32aa9f and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 94.4% (50% is the threshold).

This pull request will bring the total coverage in the repository to 92.5% (0.0% change).

View more on Code Climate.

@SimonBaeumer
Copy link
Member

merge :)

@SimonBaeumer SimonBaeumer self-requested a review October 2, 2020 09:02
@SimonBaeumer SimonBaeumer merged commit bb33069 into master Oct 2, 2020
@SimonBaeumer SimonBaeumer deleted the fetch-test-suites-over-http branch October 2, 2020 09:03
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.

2 participants