Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String const #571

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions Cargo.lock

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

30 changes: 29 additions & 1 deletion 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};
use pulumi_wasm_typesystem::{
MyEnum, UnionCase1, UnionCase2, UnionCaseWithConst1, UnionCaseWithConst2,
};
use std::panic::catch_unwind;

#[test]
Expand Down Expand Up @@ -47,6 +49,32 @@ mod tests {
assert_eq!(deserialized_enum2, enum2);
}

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

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() {
// String
let output = Output::new(&"Hello, World!".to_string());
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
Loading