|
2 | 2 |
|
3 | 3 | RSpec.describe Superset::Database::List do
|
4 | 4 | subject { described_class.new }
|
5 |
| - let(:result) do |
6 |
| - [ |
7 |
| - { |
8 |
| - id: 1, |
9 |
| - database_name: 'Test 1', |
10 |
| - backend: 'postgres', |
11 |
| - expose_in_sqllab: 'true' |
12 |
| - }, |
13 |
| - { |
14 |
| - id: 2, |
15 |
| - database_name: 'Test 2', |
16 |
| - backend: 'mysql', |
17 |
| - expose_in_sqllab: 'false' |
18 |
| - } |
19 |
| - ] |
20 |
| - end |
21 |
| - |
22 |
| - before do |
23 |
| - allow(subject).to receive(:result).and_return(result) |
| 5 | + let(:response) do |
| 6 | + { 'result' => |
| 7 | + [ |
| 8 | + { |
| 9 | + id: 1, |
| 10 | + database_name: 'Test 1', |
| 11 | + backend: 'postgres', |
| 12 | + expose_in_sqllab: 'true' |
| 13 | + }, |
| 14 | + { |
| 15 | + id: 2, |
| 16 | + database_name: 'Test 2', |
| 17 | + backend: 'mysql', |
| 18 | + expose_in_sqllab: 'false' |
| 19 | + } |
| 20 | + ] |
| 21 | + } |
24 | 22 | end
|
25 | 23 |
|
26 | 24 | describe '#rows' do
|
| 25 | + before do |
| 26 | + allow(subject).to receive(:response).and_return(response) |
| 27 | + end |
| 28 | + |
27 | 29 | specify do
|
28 | 30 | expect(subject.rows).to match_array(
|
29 | 31 | [
|
|
58 | 60 | expect(subject.query_params).to eq("filters:!((col:database_name,opr:ct,value:'acme')),page:0,page_size:100")
|
59 | 61 | end
|
60 | 62 | end
|
| 63 | + |
| 64 | + context 'with uuid_equals filters' do |
| 65 | + subject { described_class.new(uuid_equals: '123') } |
| 66 | + |
| 67 | + specify do |
| 68 | + expect(subject.query_params).to eq("filters:!((col:uuid,opr:eq,value:'123')),page:0,page_size:100") |
| 69 | + end |
| 70 | + end |
| 71 | + end |
| 72 | + |
| 73 | + describe '#response' do |
| 74 | + context 'with invalid parameters' do |
| 75 | + context 'when title_contains is not a string' do |
| 76 | + subject { described_class.new(title_contains: ['test']) } |
| 77 | + |
| 78 | + specify do |
| 79 | + expect { subject.response }.to raise_error(Superset::Request::InvalidParameterError, 'title_contains must be a String type') |
| 80 | + end |
| 81 | + end |
| 82 | + |
| 83 | + context 'when uuid_equals is not a string' do |
| 84 | + subject { described_class.new(uuid_equals: 1) } |
| 85 | + |
| 86 | + specify do |
| 87 | + expect { subject.response }.to raise_error(Superset::Request::InvalidParameterError, 'uuid_equals must be a String type') |
| 88 | + end |
| 89 | + end |
| 90 | + end |
61 | 91 | end
|
62 | 92 | end
|
0 commit comments