1
+ require 'spec_helper'
2
+
3
+ RSpec . describe Superset ::Dashboard ::Export do
4
+ subject { described_class . new ( dashboard_id : dashboard_id , destination_path : destination_path ) }
5
+ let ( :dashboard_id ) { 18 }
6
+ let ( :destination_path ) { './tmp/superset_dashboard_backups/' }
7
+
8
+ describe '#perform' do
9
+ let ( :response ) { double ( 'response' ) }
10
+ let ( :zip_file_name ) { 'spec/fixtures/dashboard_18_export_20240322.zip' } # example birth names dashboard export fixture
11
+
12
+ before do
13
+ allow ( subject ) . to receive ( :response ) . and_return ( response )
14
+ allow ( subject ) . to receive ( :zip_file_name ) . and_return ( zip_file_name )
15
+ allow ( subject ) . to receive ( :save_exported_zip_file )
16
+ end
17
+
18
+ it 'unzips into the destination path' do
19
+ subject . perform
20
+ expect ( Dir . glob ( subject . destination_path + "/**/*" ) . sort ) . to match_array ( [
21
+ "./tmp/superset_dashboard_backups/18" ,
22
+ "./tmp/superset_dashboard_backups/18/charts" ,
23
+ "./tmp/superset_dashboard_backups/18/charts/Boy_Name_Cloud_53920.yaml" ,
24
+ "./tmp/superset_dashboard_backups/18/charts/Names_Sorted_by_Num_in_California_53929.yaml" ,
25
+ "./tmp/superset_dashboard_backups/18/charts/Number_of_Girls_53930.yaml" ,
26
+ "./tmp/superset_dashboard_backups/18/charts/Pivot_Table_53931.yaml" ,
27
+ "./tmp/superset_dashboard_backups/18/charts/Top_10_Girl_Name_Share_53921.yaml" ,
28
+ "./tmp/superset_dashboard_backups/18/dashboards" ,
29
+ "./tmp/superset_dashboard_backups/18/dashboards/Birth_Names_18.yaml" ,
30
+ "./tmp/superset_dashboard_backups/18/databases" ,
31
+ "./tmp/superset_dashboard_backups/18/databases/examples.yaml" ,
32
+ "./tmp/superset_dashboard_backups/18/datasets" ,
33
+ "./tmp/superset_dashboard_backups/18/datasets/examples" ,
34
+ "./tmp/superset_dashboard_backups/18/datasets/examples/birth_names.yaml" ,
35
+ "./tmp/superset_dashboard_backups/18/metadata.yaml"
36
+ ] )
37
+ end
38
+ end
39
+ end
0 commit comments