Skip to content

Commit bd80592

Browse files
committed
Add correct accronym replacement test
1 parent 3730cb8 commit bd80592

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

packages/go-gen/src/main.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,56 @@ mod tests {
472472
}"#,
473473
);
474474
}
475+
476+
#[test]
477+
fn accronym_replacement_works() {
478+
#[cw_serde]
479+
struct IbcStruct {
480+
a: IbcSubStruct,
481+
b: IbcSubEnum,
482+
}
483+
#[cw_serde]
484+
enum IbcEnum {
485+
A(IbcSubStruct),
486+
B(IbcSubEnum),
487+
}
488+
#[cw_serde]
489+
struct IbcSubStruct {}
490+
#[cw_serde]
491+
enum IbcSubEnum {
492+
A(String),
493+
}
494+
495+
let code = generate_go(cosmwasm_schema::schema_for!(IbcStruct)).unwrap();
496+
assert_code_eq(
497+
code,
498+
r#"
499+
type IBCStruct struct {
500+
A IBCSubStruct `json:"a"`
501+
B IBCSubEnum `json:"b"`
502+
}
503+
type IBCSubEnum struct {
504+
A string `json:"a,omitempty"`
505+
}
506+
type IBCSubStruct struct {
507+
}
508+
"#,
509+
);
510+
511+
let code = generate_go(cosmwasm_schema::schema_for!(IbcEnum)).unwrap();
512+
assert_code_eq(
513+
code,
514+
r#"
515+
type IBCEnum struct {
516+
A *IBCSubStruct `json:"a,omitempty"`
517+
B *IBCSubEnum `json:"b,omitempty"`
518+
}
519+
type IBCSubEnum struct {
520+
A string `json:"a,omitempty"`
521+
}
522+
type IBCSubStruct struct {
523+
}
524+
"#,
525+
);
526+
}
475527
}

0 commit comments

Comments
 (0)