Skip to content

Commit

Permalink
feat: only seed example data when database is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Apr 16, 2019
1 parent 651d00e commit 0f2d00a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/pact_broker/db/seed_example_data.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'pact_broker/test/test_data_builder'
require 'pact_broker/pacticipants/service'

module PactBroker
module DB
Expand All @@ -8,6 +9,7 @@ def self.call
end

def call
return unless database_empty?
PactBroker::Test::TestDataBuilder.new
.create_consumer("Example App", created_at: days_ago(16))
.create_provider("Example API", created_at: days_ago(16))
Expand All @@ -30,6 +32,10 @@ def call
.create_provider_version_tag("dev", created_at: days_ago(1))
end

def database_empty?
PactBroker::Pacticipants::Service.find_all_pacticipants.empty?
end

def pact_1
seed_data_file("pact_1.json")
end
Expand Down

0 comments on commit 0f2d00a

Please sign in to comment.