diff options
| author | Robert | 2017-04-19 13:24:31 +0200 |
|---|---|---|
| committer | Robert | 2017-04-19 13:24:31 +0200 |
| commit | f18d0a349eeec0822c02b08bbee276398aa40975 (patch) | |
| tree | 7acdb75528e189978f49a3c46f1b751d9ed1cd1a /spec | |
| parent | 45da531345ce04ae388465d8bb5bb7a092a7b2e2 (diff) | |
| download | chouette-core-f18d0a349eeec0822c02b08bbee276398aa40975.tar.bz2 | |
filtered environment specific information from pg_catalog (spec support)
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/lib/af83/stored_procedures/clone_schema_spec.rb | 9 | ||||
| -rw-r--r-- | spec/support/pg_catalog.rb | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/spec/lib/af83/stored_procedures/clone_schema_spec.rb b/spec/lib/af83/stored_procedures/clone_schema_spec.rb index 69422e4ef..4de3379ea 100755 --- a/spec/lib/af83/stored_procedures/clone_schema_spec.rb +++ b/spec/lib/af83/stored_procedures/clone_schema_spec.rb @@ -16,8 +16,7 @@ RSpec.describe StoredProcedures do context "meta specs describe source schema's introspection" do it "table information is correctly read" do expect(get_table_information(source_schema, child_table)) - .to eq([{"table_catalog"=>"chouette_test", - "table_schema"=>"source_schema", + .to eq([{"table_schema"=>"source_schema", "table_name"=>"children", "table_type"=>"BASE TABLE", "self_referencing_column_name"=>nil, @@ -83,8 +82,7 @@ RSpec.describe StoredProcedures do it "table information is correctly read" do expect(get_table_information(source_schema, child_table)) - .to eq([{"table_catalog"=>"chouette_test", - "table_schema"=>"source_schema", + .to eq([{"table_schema"=>"source_schema", "table_name"=>"children", "table_type"=>"BASE TABLE", "self_referencing_column_name"=>nil, @@ -97,8 +95,7 @@ RSpec.describe StoredProcedures do "commit_action"=>nil}]) expect( get_table_information(target_schema, child_table)) - .to eq([{"table_catalog"=>"chouette_test", - "table_schema"=>"target_schema", + .to eq([{"table_schema"=>"target_schema", "table_name"=>"children", "table_type"=>"BASE TABLE", "self_referencing_column_name"=>nil, diff --git a/spec/support/pg_catalog.rb b/spec/support/pg_catalog.rb index dd0219482..30992168e 100644 --- a/spec/support/pg_catalog.rb +++ b/spec/support/pg_catalog.rb @@ -31,6 +31,7 @@ module Support def get_table_information(schema_name, table_name) execute("SELECT * FROM information_schema.tables WHERE table_name = '#{table_name}' AND table_schema = '#{schema_name}'") .to_a + .map(&without_keys("table_catalog")) end @@ -69,5 +70,13 @@ module Support def queries @__queries__ ||= {} end + + def without_keys(*keys) + -> hashy do + hashy.inject({}) do |h, (k,v)| + keys.include?(k) ? h : h.merge(k => v) + end + end + end end end |
