Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Integration tests #338

Merged
merged 21 commits into from
Oct 20, 2021
Merged

Integration tests #338

merged 21 commits into from
Oct 20, 2021

Conversation

joao-paulo-parity
Copy link
Contributor

@joao-paulo-parity joao-paulo-parity commented Oct 19, 2021

Adds an integration test and runs it on CI.

This PR includes a single simple integration test because its main purpose is to introduce the ability to running integration tests in the first place, since we don't have any. In the future, more integration tests can be added upon the code introduced here.

The original branch contained a new feature which I've not included here to reduce the scope of this PR and also due to time constraints.

closes #251

@joao-paulo-parity joao-paulo-parity marked this pull request as draft October 19, 2021 04:16
@joao-paulo-parity joao-paulo-parity marked this pull request as ready for review October 19, 2021 04:27
# --test '*' means only run the integration tests
# https://github.com/rust-lang/cargo/issues/8396#issuecomment-713126649
# --nocapture is used so that we see the commands being executed interleaved within the logged info
GIT_DAEMON_BASE_PATH_TRACKER="$git_daemon_base_path_tracker" cargo test --test '*' -- --nocapture
Copy link
Contributor

@azerella azerella Oct 19, 2021

Choose a reason for hiding this comment

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

I'd really recommend just using a proper library like https://docs.rs/git2/0.13.23/git2/ over worrying about all of this stuff, then we can simply just run cargo test maybe

Copy link
Contributor Author

@joao-paulo-parity joao-paulo-parity Oct 20, 2021

Choose a reason for hiding this comment

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

git-daemon is tricky in the sense that the daemon's process is not killed when the main process is, so I resort to this kind of measure. The library you posted does not appear to have anything related to the daemon in any case.

If you'd like to pursue this option then please open a new issue for that.

@@ -43,6 +46,12 @@ impl MainConfig {
})
.unwrap_or(false);

let github_api_url = "https://api.github.com".to_owned();
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth having this as an env var? Or setting up env vars for tests?

Copy link
Contributor Author

@joao-paulo-parity joao-paulo-parity Oct 20, 2021

Choose a reason for hiding this comment

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

For tests, each test will have its own Github mock API and so setting up an environment variable is not as clean or as reasonable as storing it in the state.

For the application, we do not have a use-case for a custom Github API and so I'd rather not introduce a new environment variable.

}

pub fn initialize_repository(repo_dir: &Path, initial_branch: &str) {
exec::<&str, PathBuf>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@joao-paulo-parity joao-paulo-parity Oct 20, 2021

Choose a reason for hiding this comment

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

I'm not opposed to using a library, but it definitely will not be done in this MR. Feel free to open a new issue for that.

Food for thought: even though using that library might subjectively might appear to be cleaner, I infer it would increase complexity because, while we can reason about git commands which we use on a daily basis, by introducing that library all maintainers would have to learn about how it works in order to deal with this function (which is merely a test helper, not actually application code). From my point-of-view the tradeoff is not worth it given that this exec interface which works well enough (including exit code, stderr visibility, etc...) for any commands we want to execute, not only git ones.

@joao-paulo-parity joao-paulo-parity merged commit 742e8c8 into master Oct 20, 2021
@joao-paulo-parity joao-paulo-parity deleted the integration-tests branch October 20, 2021 13:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integration test infrastructure
2 participants