Skip to content

Commit

Permalink
Merge pull request #2772 from alphagov/add-pact-tests-for-schema-endp…
Browse files Browse the repository at this point in the history
…oints

Add pact tests for new Schema endpoints
  • Loading branch information
pezholio authored Jun 18, 2024
2 parents 9293f17 + e358731 commit 71fae1e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions spec/service_consumers/pact_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,60 @@ def url_encode(str)
end
end

provider_state "there are publisher schemas" do
set_up do
schemas = {
"/govuk/publishing-api/content_schemas/dist/formats/email_address/publisher_v2/schema.json": {
type: "object",
required: %w[a],
properties: {
email_address: { "some" => "schema" },
},
},
"/govuk/publishing-api/content_schemas/dist/formats/tax_license/publisher_v2/schema.json": {
type: "object",
required: %w[a],
properties: {
tax_license: { "another" => "schema" },
},
},
}

allow(GovukSchemas::Schema)
.to receive(:all)
.with(schema_type: "publisher")
.and_return(schemas)
end
end

provider_state "there is a schema for an email_address" do
set_up do
email_address_schema = {
"/govuk/publishing-api/content_schemas/dist/formats/email_address/publisher_v2/schema.json": {
type: "object",
required: %w[a],
properties: {
email_address: { "some" => "schema" },
},
},
}

allow(GovukSchemas::Schema)
.to receive(:find)
.with(publisher_schema: "email_address")
.and_return(email_address_schema)
end
end

provider_state "there is not a schema for an email_address" do
set_up do
allow(GovukSchemas::Schema)
.to receive(:find)
.with(publisher_schema: "email_address")
.and_raise(Errno::ENOENT)
end
end

provider_state "no content exists" do
set_up do
stub_request(:put, Regexp.new("\\A#{Regexp.escape(Plek.find('content-store'))}/content"))
Expand Down

0 comments on commit 71fae1e

Please sign in to comment.