Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First cucumber tests for Database Load
- Loading branch information
Edouard Maffert
committed
Jun 27, 2017
1 parent
502247e
commit e5136ea
Showing
10 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ group :test do | |
gem 'netrc' | ||
gem 'http-cookie' | ||
gem 'rest-client' | ||
gem 'pg' | ||
end | ||
|
||
group :development do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Feature: Test Database Load | ||
|
||
@database | ||
Scenario: Load Referentials and partners | ||
Given the table "referentials" has the following data: | ||
| referential_id | slug | settings | tokens | | ||
| '6ba7b814-9dad-11d1-0000-00c04fd430c8' | 'first' | '{"key":"value"}' | '["testtoken"]' | | ||
| '6ba7b814-9dad-11d1-0001-00c04fd430c8' | 'second' | '{}' | '["testtoken"]' | | ||
And the table "partners" has the following data: | ||
| id | referential_id | slug | settings | connector_types | | ||
| '6ba7b814-9dad-11d1-0002-00c04fd430c8' | '6ba7b814-9dad-11d1-0000-00c04fd430c8' | 'first_partner' | '{"remote_url": "http://localhost", "remote_objectid_kind": "Reflex", "remote_credential": "edwig_cred"}' | '["siri-stop-monitoring-request-collector", "siri-check-status-client"]' | | ||
| '6ba7b814-9dad-11d1-0003-00c04fd430c8' | '6ba7b814-9dad-11d1-0001-00c04fd430c8' | 'second_partner' | '{}' | '[]' | | ||
When I start Edwig | ||
Then one Referential has the following attributes: | ||
| Id | 6ba7b814-9dad-11d1-0000-00c04fd430c8 | | ||
| Slug | first | | ||
| Settings | {"key":"value"} | | ||
And one Referential has the following attributes: | ||
| Id | 6ba7b814-9dad-11d1-0001-00c04fd430c8 | | ||
| Slug | second | | ||
And one Partner in Referential "first" has the following attributes: | ||
| Id | 6ba7b814-9dad-11d1-0002-00c04fd430c8 | | ||
| Slug | first_partner | | ||
| Settings | {"remote_url": "http://localhost", "remote_objectid_kind": "Reflex", "remote_credential": "edwig_cred"} | | ||
| ConnectorTypes | ["siri-check-status-client", "siri-stop-monitoring-request-collector"] | | ||
And one Partner in Referential "second" has the following attributes: | ||
| Id | 6ba7b814-9dad-11d1-0003-00c04fd430c8 | | ||
| Slug | second_partner | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Given(/^the table "([^"]*)" has the following data:$/) do |table_name, datas| | ||
data_array = datas.raw | ||
|
||
request_string = "INSERT INTO #{table_name} (#{data_array.shift.join(',')}) VALUES" | ||
|
||
data_array.each do |data| | ||
request_string += "(#{data.join(',')})," | ||
end | ||
request_string.gsub!(/,$/, ';') | ||
|
||
conn = PG.connect dbname: $database | ||
conn.exec(request_string) | ||
end | ||
|
||
When(/^I start Edwig$/) do | ||
start_edwig() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'pg' | ||
|
||
$database = 'edwig_test' | ||
|
||
After('@database') do | ||
# Truncate all tables | ||
conn = PG.connect dbname: $database | ||
conn.exec( | ||
"DO $$DECLARE statements CURSOR FOR | ||
SELECT table_name FROM information_schema.tables | ||
WHERE table_schema='public'; | ||
BEGIN | ||
FOR stmt IN statements LOOP | ||
IF stmt.table_name <> 'gorp_migrations' THEN | ||
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.table_name) || ' CASCADE;'; | ||
END IF; | ||
END LOOP; | ||
END$$;") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters