| 2637 | |
| 2638 | #[test] |
| 2639 | fn test_gen_with_attributes() -> io::Result<()> { |
| 2640 | let cake_entity = setup().get(0).unwrap().clone(); |
| 2641 | |
| 2642 | assert_eq!(cake_entity.get_table_name_snake_case(), "cake"); |
| 2643 | |
| 2644 | // Compact code blocks |
| 2645 | assert_eq!( |
| 2646 | comparable_file_string(include_str!( |
| 2647 | "../../tests/compact_with_attributes/cake_none.rs" |
| 2648 | ))?, |
| 2649 | generated_to_string(EntityWriter::gen_compact_code_blocks( |
| 2650 | &cake_entity, |
| 2651 | &WithSerde::None, |
| 2652 | &DateTimeCrate::Chrono, |
| 2653 | &None, |
| 2654 | false, |
| 2655 | false, |
| 2656 | &TokenStream::new(), |
| 2657 | &TokenStream::new(), |
| 2658 | false, |
| 2659 | true, |
| 2660 | )) |
| 2661 | ); |
| 2662 | assert_eq!( |
| 2663 | comparable_file_string(include_str!( |
| 2664 | "../../tests/compact_with_attributes/cake_one.rs" |
| 2665 | ))?, |
| 2666 | generated_to_string(EntityWriter::gen_compact_code_blocks( |
| 2667 | &cake_entity, |
| 2668 | &WithSerde::None, |
| 2669 | &DateTimeCrate::Chrono, |
| 2670 | &None, |
| 2671 | false, |
| 2672 | false, |
| 2673 | &TokenStream::new(), |
| 2674 | &bonus_attributes([r#"serde(rename_all = "camelCase")"#]), |
| 2675 | false, |
| 2676 | true, |
| 2677 | )) |
| 2678 | ); |
| 2679 | assert_eq!( |
| 2680 | comparable_file_string(include_str!( |
| 2681 | "../../tests/compact_with_attributes/cake_multiple.rs" |
| 2682 | ))?, |
| 2683 | generated_to_string(EntityWriter::gen_compact_code_blocks( |
| 2684 | &cake_entity, |
| 2685 | &WithSerde::None, |
| 2686 | &DateTimeCrate::Chrono, |
| 2687 | &None, |
| 2688 | false, |
| 2689 | false, |
| 2690 | &TokenStream::new(), |
| 2691 | &bonus_attributes([r#"serde(rename_all = "camelCase")"#, "ts(export)"]), |
| 2692 | false, |
| 2693 | true, |
| 2694 | )) |
| 2695 | ); |
| 2696 | |