test_helper.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. use crate::entities::{CreateViewParams, ViewLayoutPB};
  2. use crate::manager::Folder2Manager;
  3. use crate::view_ext::gen_view_id;
  4. use std::collections::HashMap;
  5. #[cfg(feature = "test_helper")]
  6. impl Folder2Manager {
  7. pub async fn create_test_grid_view(
  8. &self,
  9. app_id: &str,
  10. name: &str,
  11. ext: HashMap<String, String>,
  12. ) -> String {
  13. self
  14. .create_test_view(app_id, name, ViewLayoutPB::Grid, ext)
  15. .await
  16. }
  17. pub async fn create_test_board_view(
  18. &self,
  19. app_id: &str,
  20. name: &str,
  21. ext: HashMap<String, String>,
  22. ) -> String {
  23. self
  24. .create_test_view(app_id, name, ViewLayoutPB::Board, ext)
  25. .await
  26. }
  27. async fn create_test_view(
  28. &self,
  29. app_id: &str,
  30. name: &str,
  31. layout: ViewLayoutPB,
  32. ext: HashMap<String, String>,
  33. ) -> String {
  34. let view_id = gen_view_id();
  35. let params = CreateViewParams {
  36. belong_to_id: app_id.to_string(),
  37. name: name.to_string(),
  38. desc: "".to_string(),
  39. layout,
  40. view_id: view_id.clone(),
  41. initial_data: vec![],
  42. ext,
  43. };
  44. self.create_view_with_params(params).await.unwrap();
  45. view_id
  46. }
  47. }