Skip to content

Commit

Permalink
chore(script): update seed data
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 6, 2017
1 parent a0a7c1b commit c9272dc
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions script/seed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@
DATABASE_CREDENTIALS = {logger: Logger.new($stdout), adapter: "sqlite", database: ARGV[0], :encoding => 'utf8'}
connection = Sequel.connect(DATABASE_CREDENTIALS)
connection.timezone = :utc
require 'pact_broker/db'
PactBroker::DB.connection = connection
require 'pact_broker'
require 'support/test_data_builder'

def random_build
rand * 100
end

tables_to_clean = [:labels, :webhook_executions, :verifications, :pact_publications, :pact_versions, :pacts, :pact_version_contents, :tags, :versions, :webhook_headers, :webhooks, :pacticipants]
tables_to_clean = [:labels, :webhook_executions, :triggered_webhooks, :verifications, :pact_publications, :pact_versions, :pacts, :pact_version_contents, :tags, :versions, :webhook_headers, :webhooks, :pacticipants]

tables_to_clean.each do | table_name |
connection[table_name].delete if connection.table_exists?(table_name)
end



class TestDataBuilder
def method_missing *args
self
Expand Down Expand Up @@ -52,7 +53,7 @@ def publish_pact params = {}
.create_label("microservice")
.create_provider("Bar")
.create_label("microservice")
.create_webhook(method: 'GET', url: 'http://127.0.0.1:1234/')
.create_webhook(method: 'GET', url: 'http://localhost:9393/')
.create_consumer_version("1.2.100")
.publish_pact
.create_verification(provider_version: "1.4.234", success: true, execution_date: DateTime.now - 15)
Expand All @@ -62,7 +63,7 @@ def publish_pact params = {}
.create_consumer_version("1.2.102")
.publish_pact(created_at: (Date.today - 7).to_datetime)
.create_provider("Animals")
.create_webhook(method: 'GET', url: 'http://127.0.0.1:1234/')
.create_webhook(method: 'GET', url: 'http://localhost:9393/')
.publish_pact(created_at: (Time.now - 140).to_datetime)
.create_verification(provider_version: "2.0.366", execution_date: Date.today - 2) #changed
.create_provider("Wiffles")
Expand All @@ -73,12 +74,16 @@ def publish_pact params = {}
.publish_pact(created_at: (Date.today - 1).to_datetime)
.create_consumer("The Android App")
.create_provider("The back end")
.create_webhook(method: 'GET', url: 'http://127.0.0.1:1234/')
.create_webhook(method: 'GET', url: 'http://localhost:9393/')
.create_consumer_version("1.2.106")
.publish_pact
.create_consumer("Some other app")
.create_provider("A service")
.create_webhook(method: 'GET', url: 'http://127.0.0.1:1234/')
.create_webhook(method: 'GET', url: 'http://localhost:9393/')
.create_triggered_webhook(status: 'success')
.create_webhook_execution
.create_webhook(method: 'POST', url: 'http://foo:9393/')
.create_triggered_webhook(status: 'failure')
.create_webhook_execution
.create_consumer_version("1.2.106")
.publish_pact(created_at: (Date.today - 26).to_datetime)
Expand Down

0 comments on commit c9272dc

Please sign in to comment.