Skip to content

Commit

Permalink
Test Account deserialization from GraphQL string
Browse files Browse the repository at this point in the history
Ensure that the alternative serialization format is supported.
  • Loading branch information
jvff committed Mar 5, 2025
1 parent 5d5535a commit 3227652
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion linera-base/src/unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//! Unit tests for `linera-base` types.
use std::fmt::Debug;
use std::fmt::{Debug, Display};

use linera_witty::{Layout, WitLoad, WitStore};
use serde::{de::DeserializeOwned, Serialize};
Expand Down Expand Up @@ -63,6 +63,21 @@ where
Ok(())
}

/// Test alternative GraphQL deserialization of types from strings.
#[test_case(account_test_case(); "of_account")]
fn test_graphql_alternative_deserialization<T>(input: T) -> anyhow::Result<()>
where
T: Debug + Eq + Display + DeserializeOwned,
{
let graphql_value = async_graphql::Value::String(input.to_string());

let deserialized_value = T::deserialize(graphql_value)?;

assert_eq!(input, deserialized_value);

Ok(())
}

/// Creates a dummy [`Resources`] instance to use for the WIT roundtrip test.
fn resources_test_case() -> Resources {
Resources {
Expand Down

0 comments on commit 3227652

Please sign in to comment.