Skip to content

Commit

Permalink
test: update tests accordingly last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexD10S committed Nov 6, 2024
1 parent cf09406 commit ea538bf
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 69 deletions.
2 changes: 1 addition & 1 deletion crates/pop-cli/src/commands/up/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ mod tests {
let command = UpContractCommand {
path: None,
constructor: "new".to_string(),
args: vec!["false".to_string()].to_vec(),
args: vec![],
value: "0".to_string(),
gas_limit: None,
proof_size: None,
Expand Down
21 changes: 12 additions & 9 deletions crates/pop-contracts/src/utils/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,14 @@ mod tests {
"Constructor that initializes the `bool` value to `false`. Constructors can delegate to other constructors."
);
// assert parsed arguments
assert_eq!(constructor[0].args.len(), 2);
assert_eq!(constructor[0].args.len(), 1);
assert_eq!(constructor[0].args[0].label, "init_value".to_string());
assert_eq!(constructor[0].args[0].type_name, "bool".to_string());
assert_eq!(constructor[0].args[1].label, "number".to_string());
assert_eq!(constructor[0].args[1].type_name, "Option".to_string());
assert_eq!(constructor[1].args.len(), 2);
assert_eq!(constructor[1].args[0].label, "init_value".to_string());
assert_eq!(constructor[1].args[0].type_name, "bool".to_string());
assert_eq!(constructor[1].args[1].label, "number".to_string());
assert_eq!(constructor[1].args[1].type_name, "Option".to_string());
Ok(())
}

Expand All @@ -272,11 +275,11 @@ mod tests {
assert!(matches!(
get_constructor(&temp_dir.path().join("testing"), "wrong_constructor"),
Err(Error::InvalidConstructorName(name)) if name == "wrong_constructor".to_string()));
let constructor = get_constructor(&temp_dir.path().join("testing"), "new")?;
assert_eq!(constructor.label, "new");
let constructor = get_constructor(&temp_dir.path().join("testing"), "default")?;
assert_eq!(constructor.label, "default");
assert_eq!(
constructor.docs,
"Constructor that initializes the `bool` value to the given `init_value`."
"Constructor that initializes the `bool` value to `false`. Constructors can delegate to other constructors."
);
// assert parsed arguments
assert_eq!(constructor.args.len(), 2);
Expand Down Expand Up @@ -334,7 +337,7 @@ mod tests {
assert!(matches!(
process_function_args(
temp_dir.path().join("testing"),
"new",
"default",
Vec::new(),
FunctionType::Constructor
),
Expand All @@ -343,7 +346,7 @@ mod tests {
assert_eq!(
process_function_args(
temp_dir.path().join("testing"),
"new",
"default",
["true".to_string(), "2".to_string()].to_vec(),
FunctionType::Constructor
)?,
Expand All @@ -352,7 +355,7 @@ mod tests {
assert_eq!(
process_function_args(
temp_dir.path().join("testing"),
"new",
"default",
["true".to_string(), "".to_string()].to_vec(),
FunctionType::Constructor
)?,
Expand Down
Loading

0 comments on commit ea538bf

Please sign in to comment.