-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
791 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,25 +1,40 @@ | ||
use assert_cmd::Command; | ||
use std::fs; | ||
use std::path::PathBuf; | ||
use tempdir::TempDir; | ||
|
||
#[ignore = "TomlEditor expects to find a parachain project structure initialized with git"] | ||
#[ignore = "test fails to run"] | ||
#[test] | ||
fn add_parachain_pallet_template() { | ||
let temp_dir = TempDir::new("add-pallet-test").unwrap(); | ||
let output = temp_dir.path().join("test_lib.rs"); | ||
let source_file = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/add/lib.rs"); | ||
println!("source file : {:?}", source_file); | ||
fs::copy(&source_file, &output).unwrap(); | ||
// Setup new parachain | ||
Command::cargo_bin("pop") | ||
.unwrap() | ||
.args(&["add", "pallet", "template", "-r", "test_lib.rs"]) | ||
.current_dir(&temp_dir) | ||
.args(&["new", "parachain", "testchain"]) | ||
.assert() | ||
.success(); | ||
let contents = fs::read_to_string(&output).unwrap(); | ||
|
||
assert_eq!(contents.matches("pub use pallet_parachain_template;").count(), 1); | ||
assert_eq!(contents.matches("impl pallet_parachain_template::Config for Runtime {").count(), 1); | ||
assert_eq!(contents.matches("Template: pallet_parachain_template").count(), 1); | ||
println!("{:?}", temp_dir.path().display()); | ||
// Add pallet-parachain-template | ||
Command::cargo_bin("pop") | ||
.unwrap() | ||
.args(&["add", "pallet", "template", "-r", "runtime/src/lib.rs"]) | ||
.current_dir(&temp_dir.path().join("testchain")) | ||
.assert() | ||
.success(); | ||
|
||
let runtime_contents = | ||
fs::read_to_string(&temp_dir.path().join("testchain/runtime/src/lib.rs")).unwrap(); | ||
let runtime_manifest = | ||
fs::read_to_string(&temp_dir.path().join("testchain/runtime/Cargo.toml")).unwrap(); | ||
|
||
assert_eq!(runtime_contents.matches("pub use pallet_parachain_template;").count(), 1); | ||
assert_eq!( | ||
runtime_contents | ||
.matches("impl pallet_parachain_template::Config for Runtime {") | ||
.count(), | ||
1 | ||
); | ||
assert_eq!(runtime_contents.matches("Template: pallet_parachain_template").count(), 1); | ||
|
||
assert_eq!(runtime_manifest.matches("pallet-parachain-template").count(), 3); | ||
} |
Oops, something went wrong.