Skip to content

Commit

Permalink
Add deleted test (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortenGregersen authored Jun 14, 2024
1 parent 29558e2 commit 25f424b
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion Tests/BagbutikSpecDecoderTests/SpecTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,69 @@ final class SpecTests: XCTestCase {
}
XCTAssertEqual(errorSchemaRef, "Errors")
}


func testApplyManualPatches_MissingCertificateType() throws {
let specString = """
{
"paths": {},
"components": {
"schemas": {
"ErrorResponse" : {
"type" : "object",
"properties" : {
"errors" : {
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "string"
},
"status" : {
"type" : "string"
},
"code" : {
"type" : "string"
},
"title" : {
"type" : "string"
},
"detail" : {
"type" : "string"
},
"source" : {
"oneOf" : [ {
"$ref" : "#/components/schemas/ErrorSourcePointer"
}, {
"$ref" : "#/components/schemas/ErrorSourceParameter"
} ]
}
},
"required" : [ "code", "detail", "title", "status" ]
}
}
}
},
"CertificateType" : {
"type" : "string",
"enum" : [ "DISTRIBUTION", "DEVELOPMENT", "DEVELOPER_ID_APPLICATION" ]
}
}
}
}
"""
let jsonDecoder = JSONDecoder()
var spec = try jsonDecoder.decode(Spec.self, from: specString.data(using: .utf8)!)
try spec.applyManualPatches()

guard case .enum(let certificateTypeSchema) = spec.components.schemas["CertificateType"] else {
XCTFail(); return
}
let certificateTypeCaseValues = certificateTypeSchema.cases.map(\.value)
XCTAssertEqual(certificateTypeCaseValues.count, 4)
XCTAssertTrue(certificateTypeCaseValues.contains("DEVELOPER_ID_APPLICATION_G2"))
}

func testApplyManualPatches_Error() throws {
let specString = """
{
Expand Down

0 comments on commit 25f424b

Please sign in to comment.