Skip to content

Commit

Permalink
add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Nowak-Liebiediew committed Aug 4, 2023
1 parent 8cdf038 commit 63ff7c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
8 changes: 7 additions & 1 deletion extensions-utils/src/download_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,11 @@ pub fn download_ic_binary(replica_rev: &str, binary_name: &str, renamed_binary_n

let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let out_path = Path::new(&manifest_dir).join(renamed_binary_name);
fs::rename(binary_name, out_path).expect("Failed to move sns");
fs::rename(binary_name, &out_path).expect("Failed to move extension");
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
dfx_core::fs::set_permissions(&out_path, std::fs::Permissions::from_mode(0o777))
.expect("Failed to set permissions");
}
}
2 changes: 0 additions & 2 deletions extensions-utils/src/project/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use crate::project::error::ProjectError;
use dfx_core::config::model::canister_id_store;
use dfx_core::config::model::canister_id_store::CanisterIds;
use dfx_core::config::model::dfinity::Config;

use hyper_rustls::ConfigBuilderExt;
use reqwest::{Client, StatusCode};
use serde::Deserialize;
use serde_json::{Map, Value};
Expand Down
14 changes: 4 additions & 10 deletions extensions/nns/e2e/tests/nns.bash
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,27 @@ teardown() {
}

@test "ic-nns-init binary exists and is executable" {
dfx cache install

# it panics, but still shows help
run "$(dfx cache show)/ic-nns-init" --help
run "$(dfx cache show)/extensions/nns/ic-nns-init" --help
assert_failure
assert_output --partial "thread 'main' panicked at 'Illegal arguments:"
assert_output --partial "ic-nns-init [OPTIONS]"
assert_output --regexp "-h, --help.*Print help information"
assert_output --regexp '--version.*Print version information'

# --version fails too
run "$(dfx cache show)/ic-nns-init" --version
run "$(dfx cache show)/extensions/nns/ic-nns-init" --version
assert_failure
}

@test "ic-admin binary exists and is executable" {
dfx cache install

run "$(dfx cache show)/ic-admin" --help
run "$(dfx cache show)/extensions/nns/ic-admin" --help
assert_success
assert_output --partial 'Common command-line options for `ic-admin`'
}

@test "sns binary exists and is executable" {
dfx cache install

run "$(dfx cache show)/sns" --help
run "$(dfx cache show)/extensions/nns/sns-cli" --help
assert_failure
assert_output --partial "Initialize, deploy and interact with an SNS."
}
Expand Down
5 changes: 5 additions & 0 deletions extensions/sns/e2e/tests/sns.bash
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,8 @@ SNS_CONFIG_FILE_NAME="sns.yml"
#dfx canister id sns_root
#dfx canister id sns_swap
}

@test "sns-cli binary exists and is executable" {
run "$(dfx cache show)"/extensions/sns/sns-cli --help
assert_output --partial "Initialize, deploy and interact with an SNS"
}

0 comments on commit 63ff7c4

Please sign in to comment.