-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into cli/restore-preamble
- Loading branch information
Showing
11 changed files
with
131 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use soroban_test::TestEnv; | ||
|
||
use crate::util::HELLO_WORLD; | ||
|
||
const SOROBAN_CONTRACT_ID: &str = "SOROBAN_CONTRACT_ID=1"; | ||
|
||
fn deploy(e: &TestEnv, id: &str) { | ||
e.new_assert_cmd("contract") | ||
.arg("deploy") | ||
.arg("--wasm") | ||
.arg(HELLO_WORLD.path()) | ||
.arg("--id") | ||
.arg(id) | ||
.assert() | ||
.success(); | ||
} | ||
|
||
fn write_env_file(e: &TestEnv, contents: &str) { | ||
let env_file = e.dir().join(".env"); | ||
std::fs::write(&env_file, contents).unwrap(); | ||
assert_eq!(contents, std::fs::read_to_string(env_file).unwrap()); | ||
} | ||
|
||
#[test] | ||
fn can_read_file() { | ||
TestEnv::with_default(|e| { | ||
deploy(e, "1"); | ||
write_env_file(e, SOROBAN_CONTRACT_ID); | ||
e.new_assert_cmd("contract") | ||
.arg("invoke") | ||
.arg("--") | ||
.arg("hello") | ||
.arg("--world=world") | ||
.assert() | ||
.stdout("[\"Hello\",\"world\"]\n") | ||
.success(); | ||
}); | ||
} | ||
|
||
#[test] | ||
fn current_env_not_overwritten() { | ||
TestEnv::with_default(|e| { | ||
deploy(e, "1"); | ||
write_env_file(e, SOROBAN_CONTRACT_ID); | ||
|
||
e.new_assert_cmd("contract") | ||
.env("SOROBAN_CONTRACT_ID", "2") | ||
.arg("invoke") | ||
.arg("--") | ||
.arg("hello") | ||
.arg("--world=world") | ||
.assert() | ||
.stderr("error: parsing contract spec: contract spec not found\n"); | ||
}); | ||
} | ||
|
||
#[test] | ||
fn cli_args_have_priority() { | ||
TestEnv::with_default(|e| { | ||
deploy(e, "2"); | ||
write_env_file(e, SOROBAN_CONTRACT_ID); | ||
e.new_assert_cmd("contract") | ||
.env("SOROBAN_CONTRACT_ID", "3") | ||
.arg("invoke") | ||
.arg("--id") | ||
.arg("2") | ||
.arg("--") | ||
.arg("hello") | ||
.arg("--world=world") | ||
.assert() | ||
.stdout("[\"Hello\",\"world\"]\n"); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ mod arg_parsing; | |
mod config; | ||
|
||
mod custom_types; | ||
mod dotenv; | ||
mod invoke_sandbox; | ||
mod plugin; | ||
mod util; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters