spec/models/adhoq/execution_spec.rb in adhoq-0.3.0 vs spec/models/adhoq/execution_spec.rb in adhoq-0.4.0
- old
+ new
@@ -19,7 +19,25 @@
])
# Accessable only once
expect(execution.report.data).to be_nil
end
+
+ describe '#generate_report!' do
+ subject { -> { execution.generate_report! } }
+
+ let(:execution) { Execution.new(query: query, raw_sql: query.query, report_format: 'csv') }
+
+ context 'when execute query successfully' do
+ let(:query) { create(:adhoq_query, query: 'SELECT name, description FROM adhoq_queries') }
+
+ it { is_expected.to change { execution.status.to_s }.to('success') }
+ end
+
+ context 'when execute query failed' do
+ let(:query) { create(:adhoq_query, query: 'INVALID SQL') }
+
+ it { is_expected.to change { execution.status.to_s }.to('failure') }
+ end
+ end
end
end