Skip to content

Commit

Permalink
Add correct accronym replacement test
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Nov 10, 2023
1 parent 3730cb8 commit bd80592
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions packages/go-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,4 +472,56 @@ mod tests {
}"#,
);
}

#[test]
fn accronym_replacement_works() {
#[cw_serde]
struct IbcStruct {
a: IbcSubStruct,
b: IbcSubEnum,
}
#[cw_serde]
enum IbcEnum {
A(IbcSubStruct),
B(IbcSubEnum),
}
#[cw_serde]
struct IbcSubStruct {}
#[cw_serde]
enum IbcSubEnum {
A(String),
}

let code = generate_go(cosmwasm_schema::schema_for!(IbcStruct)).unwrap();
assert_code_eq(
code,
r#"
type IBCStruct struct {
A IBCSubStruct `json:"a"`
B IBCSubEnum `json:"b"`
}
type IBCSubEnum struct {
A string `json:"a,omitempty"`
}
type IBCSubStruct struct {
}
"#,
);

let code = generate_go(cosmwasm_schema::schema_for!(IbcEnum)).unwrap();
assert_code_eq(
code,
r#"
type IBCEnum struct {
A *IBCSubStruct `json:"a,omitempty"`
B *IBCSubEnum `json:"b,omitempty"`
}
type IBCSubEnum struct {
A string `json:"a,omitempty"`
}
type IBCSubStruct struct {
}
"#,
);
}
}

0 comments on commit bd80592

Please sign in to comment.