Skip to content

Commit

Permalink
Add new/init --snforge e2e test
Browse files Browse the repository at this point in the history
commit-id:f3b66313
  • Loading branch information
maciektr committed Jul 4, 2024
1 parent 18debdc commit 578df11
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/_check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ jobs:
ref: ${{ inputs.ref }}
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --profile=ci --no-fail-fast

snforge-init:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: foundry-rs/setup-snfoundry@v3
- run: cargo test --profile=ci --package scarb --test snforge_init new_simple -- --ignored
54 changes: 54 additions & 0 deletions scarb/tests/snforge_init.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use assert_fs::fixture::PathChild;
use assert_fs::TempDir;
use scarb::core::TomlManifest;
use scarb_test_support::command::Scarb;
use scarb_test_support::fsx::AssertFsUtf8Ext;

#[test]
#[ignore = "run this test by name"]
fn new_simple() {
let pt = TempDir::new().unwrap();

Scarb::quick_snapbox()
.arg("new")
.arg("hello")
.arg("--snforge")
.current_dir(&pt)
.assert()
.success();

let t = pt.child("hello");
assert!(t.is_dir());
assert!(t.child("Scarb.toml").is_file());
assert!(t.child("src/lib.cairo").is_file());
assert!(t.child(".gitignore").is_file());
assert!(t.child("tests").is_dir());
assert!(t.child("tests/test_contract.cairo").is_file());
assert!(t.child(".git").is_dir());

let toml_manifest = TomlManifest::read_from_path(t.child("Scarb.toml").utf8_path()).unwrap();
assert_eq!(toml_manifest.package.unwrap().name.as_str(), "hello");
let deps = toml_manifest.dependencies.unwrap();
assert_eq!(deps.len(), 1);
assert!(deps.contains_key("starknet"));
let deps = toml_manifest.dev_dependencies.unwrap();
assert_eq!(deps.len(), 1);
assert!(deps.contains_key("snforge_std"));
assert_eq!(
toml_manifest
.scripts
.unwrap()
.get("test")
.unwrap()
.as_defined()
.unwrap()
.to_string(),
"snforge test"
);

Scarb::quick_snapbox()
.arg("check")
.current_dir(&t)
.assert()
.success();
}

0 comments on commit 578df11

Please sign in to comment.