Move JSONAPITestLib tests into their own test target.

This commit is contained in:
Mathew Polzin
2019-01-13 07:16:46 -08:00
parent 060e0e3898
commit 69bb40aa00
11 changed files with 111 additions and 67 deletions
+7 -4
View File
@@ -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]
)
@@ -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)
@@ -1,5 +1,5 @@
//
// Entity+Id.swift
// EntityTestTypes.swift
// JSONAPITests
//
// Created by Mathew Polzin on 11/15/18.
@@ -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)
}
}
@@ -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
@@ -0,0 +1,14 @@
//
// EntityTestTypes.swift
// JSONAPITests
//
// Created by Mathew Polzin on 11/15/18.
//
import JSONAPI
public typealias Entity<Description: JSONAPI.EntityDescription, Meta: JSONAPI.Meta, Links: JSONAPI.Links> = JSONAPI.Entity<Description, Meta, Links, String>
public typealias BasicEntity<Description: JSONAPI.EntityDescription> = Entity<Description, NoMetadata, NoLinks>
public typealias NewEntity<Description: JSONAPI.EntityDescription, Meta: JSONAPI.Meta, Links: JSONAPI.Links> = JSONAPI.Entity<Description, Meta, Links, Unidentified>
-60
View File
@@ -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),
]
}
+2
View File
@@ -1,8 +1,10 @@
import XCTest
import JSONAPITests
import JSONAPITestLibTests
var tests = [XCTestCaseEntry]()
tests += JSONAPITests.__allTests()
tests += JSONAPITestLibTests.__allTests()
XCTMain(tests)