test(cli): Add cross env tests for gen,sync commands#1848
test(cli): Add cross env tests for gen,sync commands#1848erezrokah wants to merge 7 commits intocloudquery:mainfrom
gen,sync commands#1848Conversation
gen,sync commands
| - id: set-matrix | ||
| run: ./scripts/resolve-modules.sh | ||
| test_build: | ||
| test-build: |
There was a problem hiding this comment.
Keep casing consistent
| - main | ||
| env: | ||
| CGO_ENABLED: 0 | ||
| CQ_NO_TELEMETRY: 1 |
There was a problem hiding this comment.
I don't think we need this anymore
c1a86a3 to
3562b70
Compare
|
OK so I found cloudquery/cli/cmd/generate_test.go Line 70 in 9e3ace7 cloudquery/cli/cmd/sync_test.go Line 9 in 9e3ace7 The separation to integration tests is so we can run them on Windows/MacOS too |
…#1856) #### Summary This PR fixes cloudquery/docs#216 which is still present in v2 and causing failures in #1848. Also somehow related to #908 If you try: 1. `gen source test` 2. `gen destination postgresql` 3. `gen sync .` you'll get the follow error: ``` Loading specs from directory: . Downloading plugin from: https://github.com/cloudquery/cloudquery/releases/download/plugins/source/test/development/test_darwin_arm64.zip to: .cq/plugins/github/cloudquery/test/development/cq-source-test_darwin_arm64.zip Error: failed to sync source test: failed to get source plugin client for test: failed to download plugin: bad status: 404 Not Found. downloading https://github.com/cloudquery/cloudquery/releases/download/plugins/source/test/development/test_darwin_arm64.zip exit status 1 ``` This is because the test plugin doesn't embed the version correctly when released (and probably others too), thus reports a `development` version which is embedded in the config: ```yml kind: "source" spec: # Name of the plugin. name: "test" # Version of the plugin to use. version: "development" ... ``` Then the CLI tries to download that version from GitHub and fails. Since we already know the version from GitHub I suggest we use that one instead of the gRPC call. For local/gRPC plugins the version is not important (at the moment). The version is already set in https://github.com/cloudquery/cloudquery/blob/7a83a65446119b5339f5f3a3759f7f160a3716b4/cli/internal/plugins/plugins.go#L137 so I only needed to pass in a pointer ---
611c391 to
50e9e9b
Compare
|
OK so this PR improves on the current tests by:
|
|
Looks like the CLI v2 doesn't work on Windows https://github.com/cloudquery/cloudquery/actions/runs/3077812862/jobs/4972939978#step:7:42 |
Im not a big fan of running this test as an external process as it makes testing good and bad test cases much hard as it will involve stdout output. I specifically built the cobra in such way that it should be possible to do so via |
Is there a way to run isolated tests in a temp directory and not in the CWD? That should allow us to reduce dependencies between tests and run tests in parallel. Also I think testing stdout is not necessarily bad in the case of CLIs as that's what the user experiences. We can leverage snapshot testing on the CLI output to avoid the need to parse the it. |
Yeah I think it should be possible to do in separate directories. Also, Im not a big fan of snapshot testing :) https://medium.com/@sapegin/whats-wrong-with-snapshot-tests-37fbe20dfe8e |
I'm familiar with the article and agree that in most cases (like testing Web apps with Jest) they don't provide much value. |
107fc80 to
009ab60
Compare
98ba12d to
d1bd7aa
Compare
5f6cc22 to
b68f113
Compare
gen,sync commandsgen,sync commands
06a0bbf to
b7f639d
Compare
b7f639d to
0522d42
Compare
yevgenypats
left a comment
There was a problem hiding this comment.
Let's have a live discussion on the integration testing strategy?
cli/cmd/doc_test.go
Outdated
| @@ -1,3 +1,5 @@ | |||
| //go:build unit | |||
There was a problem hiding this comment.
maybe do !integration so it will run with regular go test ./... ?
There was a problem hiding this comment.
Also, why have integration and not integration? I think we can always run both - also for developers as those shouldn't take long. wdyt?
There was a problem hiding this comment.
This code it outdated per @hermanschaaf's comment. We don't have separate unit tests and integration tests.
This PR introduces a separate workflow that runs only the CLI unit tests on Windows and MacOS (yet to be completed):
https://github.com/cloudquery/cloudquery/pull/1848/files#diff-0dbaaba16effff4896e9054770ab112bf49ae5b1e41a70915abafeef253b9ca7R31
yevgenypats
left a comment
There was a problem hiding this comment.
Let's discuss live but see comment here - #1860 (comment)
I don't think that we need to test/maintain output snapshot/predictability of a CLI
To clarify, this PR does not introduce snapshot testing. It adds a workflow to run exiting CLI tests on Windows and Mac and changes the CLI tests so they can be executed in a temporary directory and not the CWD of the tests |
|
Replaced by #2204 |
Summary
Adds basic integration tests. The
synctest is failing due to a bug in our release pipeline (not embedding versions) which I'll fix in a separate PRUse the following steps to ensure your PR is ready to be reviewed
go fmtto format your code 🖊golangci-lint run🚨 (install golangci-lint here)