Skip to content

Commit

Permalink
Extend test data
Browse files Browse the repository at this point in the history
- Set workflow_configuration in WorkflowRun factory
- Set workflow_configuration_path by default, not
workflow_configuration_url.
- Revisit factory traits to cover the scenarios where only URL is given
  and where none of them are given.
  • Loading branch information
saraycp committed Oct 27, 2023
1 parent 6716b04 commit 6bfe480
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/api/lib/tasks/dev/workflows.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace :dev do
create(:workflow_run, :succeeded, :tag_push, token: workflow_token)
create(:workflow_run, :succeeded, token: workflow_token)
create(:workflow_run, :succeeded, :pull_request_closed, token: workflow_token)
create(:workflow_run, :with_url, token: workflow_token)
create(:workflow_run, :without_configuration_data, token: workflow_token)

# GitLab
create(:workflow_run_gitlab, token: workflow_token)
Expand Down
17 changes: 13 additions & 4 deletions src/api/spec/factories/workflow_runs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
repository_name { Faker::Lorem.word }
repository_owner { Faker::Team.creature }
response_url { 'https://api.github.com' }
workflow_configuration_path { '.obs/workflows.yml' }
workflow_configuration_url { nil }
request_headers do
<<~END_OF_HEADERS
HTTP_X_GITHUB_EVENT: pull_request
Expand All @@ -20,15 +22,22 @@
request_payload do
File.read('spec/support/files/request_payload_github_pull_request_opened.json')
end

trait 'with_configuration_path' do
workflow_configuration_path { '.obs/workflows.yml' }
workflow_configuration do
File.read('spec/support/files/workflows.yml')
end

trait 'with_configuration_url' do
trait :with_url do
workflow_configuration_path { nil }
workflow_configuration_url { 'http://example.com/workflows.yml' }
end

# Emulating the old workflow runs, before we started to store them
trait :without_configuration_data do
workflow_configuration_path { nil }
workflow_configuration_url { nil }
workflow_configuration { nil }
end

trait :pull_request_closed do
hook_action { 'closed' }
request_payload do
Expand Down

0 comments on commit 6bfe480

Please sign in to comment.