codama_nodes/contextual_value_nodes/
account_bump_value_node.rs1use crate::{CamelCaseString, HasName};
2use codama_nodes_derive::node;
3
4#[node]
5pub struct AccountBumpValueNode {
6 pub name: CamelCaseString,
8}
9
10impl From<AccountBumpValueNode> for crate::Node {
11 fn from(val: AccountBumpValueNode) -> Self {
12 crate::Node::ContextualValue(val.into())
13 }
14}
15
16impl AccountBumpValueNode {
17 pub fn new<T>(name: T) -> Self
18 where
19 T: Into<CamelCaseString>,
20 {
21 Self { name: name.into() }
22 }
23}
24
25impl HasName for AccountBumpValueNode {
26 fn name(&self) -> &CamelCaseString {
27 &self.name
28 }
29}
30
31#[cfg(test)]
32mod tests {
33 use super::*;
34
35 #[test]
36 fn new() {
37 let node = AccountBumpValueNode::new("my_account");
38 assert_eq!(node.name, CamelCaseString::new("myAccount"));
39 }
40
41 #[test]
42 fn to_json() {
43 let node = AccountBumpValueNode::new("myAccount");
44 let json = serde_json::to_string(&node).unwrap();
45 assert_eq!(
46 json,
47 r#"{"kind":"accountBumpValueNode","name":"myAccount"}"#
48 );
49 }
50
51 #[test]
52 fn from_json() {
53 let json = r#"{"kind":"accountBumpValueNode","name":"myAccount"}"#;
54 let node: AccountBumpValueNode = serde_json::from_str(json).unwrap();
55 assert_eq!(node, AccountBumpValueNode::new("myAccount"));
56 }
57}