Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Oct 13, 2016
1 parent d7a4daf commit edec439
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Tests/FluentTests/RelationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ class RelationTests: XCTestCase {
("testBelongsToMany", testBelongsToMany),
]

var memory: MemoryDriver!
var database: Database!
override func setUp() {
database = Database(MemoryDriver())
memory = MemoryDriver()
database = Database(memory)
}

func testHasMany() throws {
Expand All @@ -25,11 +27,27 @@ class RelationTests: XCTestCase {
}

func testBelongsToMany() throws {
let hydrogen = try Atom(node: [
"id": 42,
Atom.database = database
Compound.database = database
Pivot<Atom, Compound>.database = database

var hydrogen = try Atom(node: [
"name": "Hydrogen",
"group_id": 1337
])
try hydrogen.save()
hydrogen.id = 42
try hydrogen.save()

var water = try Compound(node: [
"name": "Water"
])
try water.save()
water.id = 1337
try water.save()

var pivot = Pivot<Atom, Compound>(hydrogen, water)
try pivot.save()

_ = try hydrogen.compounds().all()
}
Expand Down

0 comments on commit edec439

Please sign in to comment.