Skip to content

Commit

Permalink
update to latest JSONAPI release candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpolzin committed May 30, 2020
1 parent 4cb17cc commit 4e479f5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
12 changes: 6 additions & 6 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
"repositoryURL": "https://github.com/llvm-swift/FileCheck.git",
"state": {
"branch": null,
"revision": "9ed91cc30a1a325d989fac117f3f3065a16b9f76",
"version": "0.2.3"
"revision": "f25bfb4c69b9e05bf6b8d0862dcedb875c1b0f68",
"version": "0.2.4"
}
},
{
"package": "JSONAPI",
"repositoryURL": "https://github.com/mattpolzin/JSONAPI",
"state": {
"branch": null,
"revision": "bbd6db6d7a999c4109b4166a726a59157d16d875",
"version": "4.0.0-alpha.2"
"revision": "5b0a01620954ba89c7d1d8f82dfcbf6fd777d17e",
"version": "4.0.0-rc.3.2"
}
},
{
"package": "Poly",
"repositoryURL": "https://github.com/mattpolzin/Poly",
"state": {
"branch": null,
"revision": "9031b8497e025cbcfae196e59eecad5ba988e267",
"version": "2.4.0"
"revision": "36ba3f624bffa34f5f9b9c7648eab3cfdcab4748",
"version": "2.5.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/typelift/SwiftCheck", .upToNextMinor(from: "0.12.0")),
.package(url: "https://github.com/mattpolzin/JSONAPI", from: "4.0.0-alpha.2"),
.package(url: "https://github.com/mattpolzin/JSONAPI", from: "4.0.0-alpha.3.2"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
17 changes: 13 additions & 4 deletions Sources/JSONAPIArbitrary/Relationship+Arbitrary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftCheck
import JSONAPI

extension ToOneRelationship: Arbitrary where Identifiable.Identifier: Arbitrary, MetaType: Arbitrary, LinksType: Arbitrary {
extension ToOneRelationship: Arbitrary where Identifiable.ID: Arbitrary, MetaType: Arbitrary, LinksType: Arbitrary {
public static var arbitrary: Gen<ToOneRelationship<Identifiable, MetaType, LinksType>> {
return Gen.compose { c in
return .init(id: c.generate(),
Expand All @@ -23,7 +23,7 @@ extension ToOneRelationship where MetaType: Arbitrary, LinksType: Arbitrary {
/// point to one of the given entities. This allows you to create
/// arbitrary relationships that make sense in a broader context where
/// the relationship must actually point to another entity.
public static func arbitrary<E: ResourceObjectType>(givenEntities: [E]) -> Gen<ToOneRelationship<Identifiable, MetaType, LinksType>> where E.Id == Identifiable.Identifier {
public static func arbitrary<E: ResourceObjectType>(givenEntities: [E]) -> Gen<ToOneRelationship<Identifiable, MetaType, LinksType>> where E.Id == Identifiable.ID {

return Gen.compose { c in
let idGen = Gen.fromElements(of: givenEntities).map { $0.id }
Expand All @@ -34,7 +34,7 @@ extension ToOneRelationship where MetaType: Arbitrary, LinksType: Arbitrary {
}
}

extension ToManyRelationship: Arbitrary where Relatable.Identifier: Arbitrary, MetaType: Arbitrary, LinksType: Arbitrary {
extension ToManyRelationship: Arbitrary where Relatable.ID: Arbitrary, MetaType: Arbitrary, LinksType: Arbitrary {
public static var arbitrary: Gen<ToManyRelationship<Relatable, MetaType, LinksType>> {
return Gen.compose { c in
return .init(ids: c.generate(),
Expand All @@ -49,7 +49,7 @@ extension ToManyRelationship where MetaType: Arbitrary, LinksType: Arbitrary {
/// point to some number of the given entities. This allows you to create
/// arbitrary relationships that make sense in a broader context where
/// the relationship must actually point to other existing entities.
public static func arbitrary<E: ResourceObjectType>(givenEntities: [E]) -> Gen<ToManyRelationship<Relatable, MetaType, LinksType>> where E.Id == Relatable.Identifier {
public static func arbitrary<E: ResourceObjectType>(givenEntities: [E]) -> Gen<ToManyRelationship<Relatable, MetaType, LinksType>> where E.Id == Relatable.ID {
return Gen.compose { c in
let idsGen = Gen.fromElements(of: givenEntities).map { $0.id }.proliferate
return .init(ids: c.generate(using: idsGen),
Expand All @@ -58,3 +58,12 @@ extension ToManyRelationship where MetaType: Arbitrary, LinksType: Arbitrary {
}
}
}

extension MetaRelationship: Arbitrary where MetaType: Arbitrary, LinksType: Arbitrary {
public static var arbitrary: Gen<MetaRelationship<MetaType, LinksType>> {
return Gen.compose { c in
return .init(meta: c.generate(),
links: c.generate())
}
}
}

0 comments on commit 4e479f5

Please sign in to comment.