Skip to content

Commit

Permalink
Make tests run synchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
3lvis committed Sep 5, 2016
1 parent 576f65d commit 31da491
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
11 changes: 7 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PODS:
- DATAObjectIDs (~> 0.6.0)
- DATAObjectIDs (0.6.0)
- DATASource (5.10.0)
- DATAStack (5.4.1)
- DATAStack (5.4.2)
- DateParser (0.1.0)
- JSON (4.0.2)
- NSDictionary-ANDYSafeValue (0.3.1)
Expand All @@ -14,12 +14,14 @@ PODS:
- NSEntityDescription-SYNCPrimaryKey (~> 1.2.4)
- NSString-HYPNetworking (~> 1.0.3)
- NSString-HYPNetworking (1.0.3)
- Sync (1.13.2):
- Sync (1.13.3):
- DATAFilter (~> 0.11.2)
- DATAStack (~> 5.4.1)
- NSDictionary-ANDYSafeValue (~> 0.3.1)
- NSEntityDescription-SYNCPrimaryKey (~> 1.2.4)
- NSManagedObject-HYPPropertyMapper (~> 4.0.1)
- TestCheck (~> 0.3.1)
- TestCheck (0.3.1)

DEPENDENCIES:
- DATASource
Expand All @@ -34,14 +36,15 @@ SPEC CHECKSUMS:
DATAFilter: 1d339e27caf0a72d895a1ae664e044fff368a520
DATAObjectIDs: e3d50315134d21009f3b34983bcf44e74d8ab54a
DATASource: 444542bc20734886c3fa46f53ec4b1dbee750950
DATAStack: f38d3fa8405fdb84066241c7d3215a5e056c5691
DATAStack: 931ef9a21c6badd0ff5de494a5d49109ba7e8115
DateParser: 6609ccde5a21650e2f61cea718a2e5c6c34ce4e8
JSON: d08f22c3e523be050d5d5f40bca43ec02d95b2cc
NSDictionary-ANDYSafeValue: 2d7adf339b6e302d71fec5f1d71ae00aacda993e
NSEntityDescription-SYNCPrimaryKey: 8f3024bddb098157b08710dc29a011e9948c5ed8
NSManagedObject-HYPPropertyMapper: 2b42481a261b467024f6b6096fbe0a307a5198e3
NSString-HYPNetworking: d4cc1047b85a02bdadd90c51b5d497e07d812efc
Sync: 66152c697389f0b48749badb931971688e8b572b
Sync: a0ce1ad9b83c364300939cf509fea79ab808aacd
TestCheck: 9a9aad0a356703989f4f2b640b6ed95e53e2214f

PODFILE CHECKSUM: a4ce83b9a5d0f8218c6d94acc4cfa26b0d4000d6

Expand Down
7 changes: 6 additions & 1 deletion Source/Sync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import NSEntityDescription_SYNCPrimaryKey
import DATAFilter
import NSManagedObject_HYPPropertyMapper
import DATAStack
import TestCheck

@objc public class Sync: NSOperation {
var downloadFinished = false
Expand Down Expand Up @@ -249,8 +250,12 @@ import DATAStack
}
}

dispatch_async(dispatch_get_main_queue()) {
if TestCheck.isTesting {
completion?(error: syncError)
} else {
dispatch_async(dispatch_get_main_queue()) {
completion?(error: syncError)
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion Sync.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sync"
s.version = "1.13.2"
s.version = "1.13.3"
s.summary = "Modern Swift JSON synchronization to Core Data"
s.description = <<-DESC
**Sync** eases your everyday job of parsing a `JSON` response and getting it into Core Data. It uses a convention-over-configuration paradigm to facilitate your workflow.
Expand Down Expand Up @@ -33,4 +33,5 @@ s.dependency 'DATAStack', '~> 5.4.1'
s.dependency 'NSDictionary-ANDYSafeValue', '~> 0.3.1'
s.dependency 'NSEntityDescription-SYNCPrimaryKey', '~> 1.2.4'
s.dependency 'NSManagedObject-HYPPropertyMapper', '~> 4.0.1'
s.dependency 'TestCheck', '~> 0.3.1'
end
11 changes: 11 additions & 0 deletions Tests/SyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ import Sync
import CoreData

class SyncTests: XCTestCase {
func testSynchronous() {
let dataStack = Helper.dataStackWithModelName("Camelcase")
let objects = Helper.objectsFromJSON("camelcase.json") as! [[String : AnyObject]]
var synchronous = false
Sync.changes(objects, inEntityNamed: "NormalUser", dataStack: dataStack) { _ in
synchronous = true
}
XCTAssertTrue(synchronous)
try! dataStack.drop()
}

// MARK: - Camelcase
func testAutomaticCamelcaseMapping() {
let dataStack = Helper.dataStackWithModelName("Camelcase")
Expand Down

0 comments on commit 31da491

Please sign in to comment.