Skip to content

Commit

Permalink
Merge pull request #81 from alphagov/test-repo
Browse files Browse the repository at this point in the history
Move `TestRepository` into `lib/`
  • Loading branch information
csutter authored Oct 31, 2023
2 parents 968d5e8 + 0b0ef60 commit cf4198a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
1 change: 1 addition & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "active_support/core_ext/integer/time"
require "repositories/test_repository"

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
Expand Down
26 changes: 26 additions & 0 deletions lib/repositories/test_repository.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# A fake repository for end-to-end testing purposes
class TestRepository
attr_reader :documents

def initialize(documents = {})
@documents = documents
end

def exists?(content_id)
documents.key?(content_id)
end

def get(content_id)
documents[content_id]
end

# rubocop:disable Lint/UnusedMethodArgument
def put(content_id, metadata, content: nil, payload_version: nil)
documents[content_id] = { metadata:, content: }
end

def delete(content_id, payload_version: nil)
documents.delete(content_id)
end
# rubocop:enable Lint/UnusedMethodArgument
end
2 changes: 1 addition & 1 deletion spec/lib/document_sync_worker_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "govuk_message_queue_consumer/test_helpers"

RSpec.describe "Document sync worker end-to-end" do
let(:repository) { DocumentSyncWorker::Repositories::TestRepository.new(documents) }
let(:repository) { TestRepository.new(documents) }
let(:message) { GovukMessageQueueConsumer::MockMessage.new(payload) }

before do
Expand Down
30 changes: 0 additions & 30 deletions spec/support/repositories/test_repository.rb

This file was deleted.

0 comments on commit cf4198a

Please sign in to comment.