From 69bb40aa008cca74b3131752c68ce5b555df0415 Mon Sep 17 00:00:00 2001 From: Mathew Polzin Date: Sun, 13 Jan 2019 07:16:46 -0800 Subject: [PATCH] Move JSONAPITestLib tests into their own test target. --- Package.swift | 11 +-- .../Attribute+LiteralTests.swift | 0 .../EntityCheckTests.swift | 4 +- .../Id+LiteralTests.swift | 0 .../Relationship+LiteralTests.swift | 0 .../Test Helpers/EntityTestTypes.swift} | 2 +- .../String+CreatableRawIdType.swift | 17 +++++ .../JSONAPITestLibTests/XCTestManifests.swift | 68 +++++++++++++++++++ .../Test Helpers/EntityTestTypes.swift | 14 ++++ Tests/JSONAPITests/XCTestManifests.swift | 60 ---------------- Tests/LinuxMain.swift | 2 + 11 files changed, 111 insertions(+), 67 deletions(-) rename Tests/{JSONAPITests/JSONAPITestLib => JSONAPITestLibTests}/Attribute+LiteralTests.swift (100%) rename Tests/{JSONAPITests/JSONAPITestLib => JSONAPITestLibTests}/EntityCheckTests.swift (96%) rename Tests/{JSONAPITests/JSONAPITestLib => JSONAPITestLibTests}/Id+LiteralTests.swift (100%) rename Tests/{JSONAPITests/JSONAPITestLib => JSONAPITestLibTests}/Relationship+LiteralTests.swift (100%) rename Tests/{JSONAPITests/Test Helpers/Entity+Id.swift => JSONAPITestLibTests/Test Helpers/EntityTestTypes.swift} (95%) create mode 100644 Tests/JSONAPITestLibTests/Test Helpers/String+CreatableRawIdType.swift create mode 100644 Tests/JSONAPITestLibTests/XCTestManifests.swift create mode 100644 Tests/JSONAPITests/Test Helpers/EntityTestTypes.swift diff --git a/Package.swift b/Package.swift index c51c7eb..2797017 100644 --- a/Package.swift +++ b/Package.swift @@ -20,12 +20,15 @@ let package = Package( .target( name: "JSONAPI", dependencies: ["Poly"]), - .target( - name: "JSONAPITestLib", - dependencies: ["JSONAPI"]), + .target( + name: "JSONAPITestLib", + dependencies: ["JSONAPI"]), .testTarget( name: "JSONAPITests", - dependencies: ["JSONAPITestLib"]) + dependencies: ["JSONAPI", "JSONAPITestLib"]), + .testTarget( + name: "JSONAPITestLibTests", + dependencies: ["JSONAPI", "JSONAPITestLib"]) ], swiftLanguageVersions: [.v4_2] ) diff --git a/Tests/JSONAPITests/JSONAPITestLib/Attribute+LiteralTests.swift b/Tests/JSONAPITestLibTests/Attribute+LiteralTests.swift similarity index 100% rename from Tests/JSONAPITests/JSONAPITestLib/Attribute+LiteralTests.swift rename to Tests/JSONAPITestLibTests/Attribute+LiteralTests.swift diff --git a/Tests/JSONAPITests/JSONAPITestLib/EntityCheckTests.swift b/Tests/JSONAPITestLibTests/EntityCheckTests.swift similarity index 96% rename from Tests/JSONAPITests/JSONAPITestLib/EntityCheckTests.swift rename to Tests/JSONAPITestLibTests/EntityCheckTests.swift index cf4a802..c59ac1d 100644 --- a/Tests/JSONAPITests/JSONAPITestLib/EntityCheckTests.swift +++ b/Tests/JSONAPITestLibTests/EntityCheckTests.swift @@ -9,8 +9,8 @@ import XCTest import JSONAPI import JSONAPITestLib -// Successes are fairly well-checked by the EntityTests. We will confirm failure cases are working -// in this file. +// Successes are fairly well-checked by the EntityTests in the JSONAPITests target. +// We will confirm failure cases are working in this file. class EntityCheckTests: XCTestCase { func test_failsWithEnumAttributes() { let entity = EnumAttributesEntity(attributes: .hello, relationships: .none, meta: .none, links: .none) diff --git a/Tests/JSONAPITests/JSONAPITestLib/Id+LiteralTests.swift b/Tests/JSONAPITestLibTests/Id+LiteralTests.swift similarity index 100% rename from Tests/JSONAPITests/JSONAPITestLib/Id+LiteralTests.swift rename to Tests/JSONAPITestLibTests/Id+LiteralTests.swift diff --git a/Tests/JSONAPITests/JSONAPITestLib/Relationship+LiteralTests.swift b/Tests/JSONAPITestLibTests/Relationship+LiteralTests.swift similarity index 100% rename from Tests/JSONAPITests/JSONAPITestLib/Relationship+LiteralTests.swift rename to Tests/JSONAPITestLibTests/Relationship+LiteralTests.swift diff --git a/Tests/JSONAPITests/Test Helpers/Entity+Id.swift b/Tests/JSONAPITestLibTests/Test Helpers/EntityTestTypes.swift similarity index 95% rename from Tests/JSONAPITests/Test Helpers/Entity+Id.swift rename to Tests/JSONAPITestLibTests/Test Helpers/EntityTestTypes.swift index 3ad2dde..23e6b7d 100644 --- a/Tests/JSONAPITests/Test Helpers/Entity+Id.swift +++ b/Tests/JSONAPITestLibTests/Test Helpers/EntityTestTypes.swift @@ -1,5 +1,5 @@ // -// Entity+Id.swift +// EntityTestTypes.swift // JSONAPITests // // Created by Mathew Polzin on 11/15/18. diff --git a/Tests/JSONAPITestLibTests/Test Helpers/String+CreatableRawIdType.swift b/Tests/JSONAPITestLibTests/Test Helpers/String+CreatableRawIdType.swift new file mode 100644 index 0000000..dd3c8f7 --- /dev/null +++ b/Tests/JSONAPITestLibTests/Test Helpers/String+CreatableRawIdType.swift @@ -0,0 +1,17 @@ +// +// String+CreatableRawIdType.swift +// JSONAPITests +// +// Created by Mathew Polzin on 11/12/18. +// + +import JSONAPI + +private var uniqueStringCounter = 0 + +extension String: CreatableRawIdType { + public static func unique() -> String { + uniqueStringCounter += 1 + return String(uniqueStringCounter) + } +} diff --git a/Tests/JSONAPITestLibTests/XCTestManifests.swift b/Tests/JSONAPITestLibTests/XCTestManifests.swift new file mode 100644 index 0000000..3da4318 --- /dev/null +++ b/Tests/JSONAPITestLibTests/XCTestManifests.swift @@ -0,0 +1,68 @@ +import XCTest + +extension Attribute_LiteralTests { + static let __allTests = [ + ("test_ArrayLiteral", test_ArrayLiteral), + ("test_BooleanLiteral", test_BooleanLiteral), + ("test_DictionaryLiteral", test_DictionaryLiteral), + ("test_FloatLiteral", test_FloatLiteral), + ("test_IntegerLiteral", test_IntegerLiteral), + ("test_NilLiteral", test_NilLiteral), + ("test_NullableArrayLiteral", test_NullableArrayLiteral), + ("test_NullableBooleanLiteral", test_NullableBooleanLiteral), + ("test_NullableDictionaryLiteral", test_NullableDictionaryLiteral), + ("test_NullableFloatLiteral", test_NullableFloatLiteral), + ("test_NullableIntegerLiteral", test_NullableIntegerLiteral), + ("test_NullableOptionalArrayLiteral", test_NullableOptionalArrayLiteral), + ("test_NullableOptionalBooleanLiteral", test_NullableOptionalBooleanLiteral), + ("test_NullableOptionalDictionaryLiteral", test_NullableOptionalDictionaryLiteral), + ("test_NullableOptionalFloatLiteral", test_NullableOptionalFloatLiteral), + ("test_NullableOptionalIntegerLiteral", test_NullableOptionalIntegerLiteral), + ("test_NullableOptionalStringLiteral", test_NullableOptionalStringLiteral), + ("test_NullableStringLiteral", test_NullableStringLiteral), + ("test_OptionalArrayLiteral", test_OptionalArrayLiteral), + ("test_OptionalBooleanLiteral", test_OptionalBooleanLiteral), + ("test_OptionalDictionaryLiteral", test_OptionalDictionaryLiteral), + ("test_OptionalFloatLiteral", test_OptionalFloatLiteral), + ("test_OptionalIntegerLiteral", test_OptionalIntegerLiteral), + ("test_OptionalNilLiteral", test_OptionalNilLiteral), + ("test_OptionalStringLiteral", test_OptionalStringLiteral), + ("test_StringLiteral", test_StringLiteral), + ] +} + +extension EntityCheckTests { + static let __allTests = [ + ("test_failsWithBadAttribute", test_failsWithBadAttribute), + ("test_failsWithBadRelationship", test_failsWithBadRelationship), + ("test_failsWithEnumAttributes", test_failsWithEnumAttributes), + ("test_failsWithEnumRelationships", test_failsWithEnumRelationships), + ("test_failsWithOptionalArrayAttribute", test_failsWithOptionalArrayAttribute), + ] +} + +extension Id_LiteralTests { + static let __allTests = [ + ("test_IntegerLiteral", test_IntegerLiteral), + ("test_StringLiteral", test_StringLiteral), + ] +} + +extension Relationship_LiteralTests { + static let __allTests = [ + ("test_ArrayLiteral", test_ArrayLiteral), + ("test_NilLiteral", test_NilLiteral), + ("test_StringLiteral", test_StringLiteral), + ] +} + +#if !os(macOS) +public func __allTests() -> [XCTestCaseEntry] { + return [ + testCase(Attribute_LiteralTests.__allTests), + testCase(EntityCheckTests.__allTests), + testCase(Id_LiteralTests.__allTests), + testCase(Relationship_LiteralTests.__allTests), + ] +} +#endif diff --git a/Tests/JSONAPITests/Test Helpers/EntityTestTypes.swift b/Tests/JSONAPITests/Test Helpers/EntityTestTypes.swift new file mode 100644 index 0000000..23e6b7d --- /dev/null +++ b/Tests/JSONAPITests/Test Helpers/EntityTestTypes.swift @@ -0,0 +1,14 @@ +// +// EntityTestTypes.swift +// JSONAPITests +// +// Created by Mathew Polzin on 11/15/18. +// + +import JSONAPI + +public typealias Entity = JSONAPI.Entity + +public typealias BasicEntity = Entity + +public typealias NewEntity = JSONAPI.Entity diff --git a/Tests/JSONAPITests/XCTestManifests.swift b/Tests/JSONAPITests/XCTestManifests.swift index d225cb5..32b0c0a 100644 --- a/Tests/JSONAPITests/XCTestManifests.swift +++ b/Tests/JSONAPITests/XCTestManifests.swift @@ -31,37 +31,6 @@ extension Attribute_FunctorTests { ] } -extension Attribute_LiteralTests { - static let __allTests = [ - ("test_ArrayLiteral", test_ArrayLiteral), - ("test_BooleanLiteral", test_BooleanLiteral), - ("test_DictionaryLiteral", test_DictionaryLiteral), - ("test_FloatLiteral", test_FloatLiteral), - ("test_IntegerLiteral", test_IntegerLiteral), - ("test_NilLiteral", test_NilLiteral), - ("test_NullableArrayLiteral", test_NullableArrayLiteral), - ("test_NullableBooleanLiteral", test_NullableBooleanLiteral), - ("test_NullableDictionaryLiteral", test_NullableDictionaryLiteral), - ("test_NullableFloatLiteral", test_NullableFloatLiteral), - ("test_NullableIntegerLiteral", test_NullableIntegerLiteral), - ("test_NullableOptionalArrayLiteral", test_NullableOptionalArrayLiteral), - ("test_NullableOptionalBooleanLiteral", test_NullableOptionalBooleanLiteral), - ("test_NullableOptionalDictionaryLiteral", test_NullableOptionalDictionaryLiteral), - ("test_NullableOptionalFloatLiteral", test_NullableOptionalFloatLiteral), - ("test_NullableOptionalIntegerLiteral", test_NullableOptionalIntegerLiteral), - ("test_NullableOptionalStringLiteral", test_NullableOptionalStringLiteral), - ("test_NullableStringLiteral", test_NullableStringLiteral), - ("test_OptionalArrayLiteral", test_OptionalArrayLiteral), - ("test_OptionalBooleanLiteral", test_OptionalBooleanLiteral), - ("test_OptionalDictionaryLiteral", test_OptionalDictionaryLiteral), - ("test_OptionalFloatLiteral", test_OptionalFloatLiteral), - ("test_OptionalIntegerLiteral", test_OptionalIntegerLiteral), - ("test_OptionalNilLiteral", test_OptionalNilLiteral), - ("test_OptionalStringLiteral", test_OptionalStringLiteral), - ("test_StringLiteral", test_StringLiteral), - ] -} - extension ComputedPropertiesTests { static let __allTests = [ ("test_ComputedAttributeAccess", test_ComputedAttributeAccess), @@ -184,16 +153,6 @@ extension DocumentTests { ] } -extension EntityCheckTests { - static let __allTests = [ - ("test_failsWithBadAttribute", test_failsWithBadAttribute), - ("test_failsWithBadRelationship", test_failsWithBadRelationship), - ("test_failsWithEnumAttributes", test_failsWithEnumAttributes), - ("test_failsWithEnumRelationships", test_failsWithEnumRelationships), - ("test_failsWithOptionalArrayAttribute", test_failsWithOptionalArrayAttribute), - ] -} - extension EntityTests { static let __allTests = [ ("test_copyIdentifiedByType", test_copyIdentifiedByType), @@ -267,13 +226,6 @@ extension EntityTests { ] } -extension Id_LiteralTests { - static let __allTests = [ - ("test_IntegerLiteral", test_IntegerLiteral), - ("test_StringLiteral", test_StringLiteral), - ] -} - extension IncludedTests { static let __allTests = [ ("test_appending", test_appending), @@ -398,14 +350,6 @@ extension RelationshipTests { ] } -extension Relationship_LiteralTests { - static let __allTests = [ - ("test_ArrayLiteral", test_ArrayLiteral), - ("test_NilLiteral", test_NilLiteral), - ("test_StringLiteral", test_StringLiteral), - ] -} - extension ResourceBodyTests { static let __allTests = [ ("test_initializers", test_initializers), @@ -425,20 +369,16 @@ public func __allTests() -> [XCTestCaseEntry] { testCase(APIDescriptionTests.__allTests), testCase(AttributeTests.__allTests), testCase(Attribute_FunctorTests.__allTests), - testCase(Attribute_LiteralTests.__allTests), testCase(ComputedPropertiesTests.__allTests), testCase(CustomAttributesTests.__allTests), testCase(DocumentTests.__allTests), - testCase(EntityCheckTests.__allTests), testCase(EntityTests.__allTests), - testCase(Id_LiteralTests.__allTests), testCase(IncludedTests.__allTests), testCase(LinksTests.__allTests), testCase(NonJSONAPIRelatableTests.__allTests), testCase(PolyProxyTests.__allTests), testCase(PolyTests.__allTests), testCase(RelationshipTests.__allTests), - testCase(Relationship_LiteralTests.__allTests), testCase(ResourceBodyTests.__allTests), ] } diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index 7841b69..ea07a7d 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -1,8 +1,10 @@ import XCTest import JSONAPITests +import JSONAPITestLibTests var tests = [XCTestCaseEntry]() tests += JSONAPITests.__allTests() +tests += JSONAPITestLibTests.__allTests() XCTMain(tests)