Skip to content

Commit

Permalink
String const
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejressel committed Dec 15, 2024
1 parent 9523632 commit 27131a6
Show file tree
Hide file tree
Showing 606 changed files with 3,105 additions and 3,069 deletions.
31 changes: 22 additions & 9 deletions examples/typesystem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ mod tests {
use pulumi_wasm_provider_common::OneOf2;
use pulumi_wasm_rust::Output;
use pulumi_wasm_typesystem::typesystem_server::TypesystemServerArgs;
use pulumi_wasm_typesystem::{MyEnum, UnionCase1, UnionCase2, UnionCaseWithConst1, UnionCaseWithConst2};
use pulumi_wasm_typesystem::{
MyEnum, UnionCase1, UnionCase2, UnionCaseWithConst1, UnionCaseWithConst2,
};
use std::panic::catch_unwind;

#[test]
Expand Down Expand Up @@ -49,17 +51,28 @@ mod tests {

#[test]
fn test_case_deserialization_with_oneof2() {
let oneof: OneOf2<UnionCaseWithConst1, UnionCaseWithConst2> = OneOf2::Left(
let oneof1: OneOf2<UnionCaseWithConst1, UnionCaseWithConst2> = OneOf2::Left(
UnionCaseWithConst1::builder()
.field_1("value1".to_string())
.build_struct(),
.field_1("value1".to_string())
.build_struct(),
);
let oneof2: OneOf2<UnionCaseWithConst1, UnionCaseWithConst2> = OneOf2::Right(
UnionCaseWithConst2::builder()
.field_2("value2".to_string())
.build_struct(),
);

let json = serde_json::to_string(&oneof).unwrap();
assert_eq!(json, r#"{"field1":"value1"}"#);

let deserialized: OneOf2<UnionCaseWithConst1, UnionCaseWithConst2> = serde_json::from_str(&json).unwrap();
assert_eq!(deserialized, oneof);
let json1 = serde_json::to_string(&oneof1).unwrap();
let json2 = serde_json::to_string(&oneof2).unwrap();
assert_eq!(json1, r#"{"field":"1","field1":"value1"}"#);
assert_eq!(json2, r#"{"field":"2","field2":"value2"}"#);

let deserialized1: OneOf2<UnionCaseWithConst1, UnionCaseWithConst2> =
serde_json::from_str(&json1).unwrap();
let deserialized2: OneOf2<UnionCaseWithConst1, UnionCaseWithConst2> =
serde_json::from_str(&json2).unwrap();
assert_eq!(deserialized1, oneof1);
assert_eq!(deserialized2, oneof2);
}

fn compilation_test() {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 27131a6

Please sign in to comment.