Skip to content

Commit

Permalink
RealmV2 support (#5)
Browse files Browse the repository at this point in the history
* Removed *Copy Frameworks*

* Swift 3.0

* Add method to save event

* Update realm to v2

* Clear test data

* Use different InMemoryRealm for each test case
  • Loading branch information
ykyouhei authored and uny committed Feb 8, 2017
1 parent 810439f commit 91a2910
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "realm/realm-cocoa"
github "realm/realm-cocoa" ~> 2.0
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "realm/realm-cocoa" "v1.1.0"
github "realm/realm-cocoa" "v2.4.2"
2 changes: 1 addition & 1 deletion Source/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal final class Event: RealmSwift.Object {
try realm?.write{
realm?.add(self)
}
} catch RealmSwift.Error.addressSpaceExhausted {
} catch Realm.Error.addressSpaceExhausted {
shouldDeleteRealmFiles = true
} catch let error {
if configuration.debug {
Expand Down
4 changes: 2 additions & 2 deletions Source/Uploader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ internal struct Uploader {


let numberOfUploadingEvents = min(events.count, limit)
let targetEvents = Array(events.sorted(byProperty: "timestamp").prefix(numberOfUploadingEvents))
let targetEvents = Array(events.sorted(byKeyPath: #keyPath(Event.timestamp)).prefix(numberOfUploadingEvents))

self.uploadEvents(events: targetEvents) { result, responseJson in
guard let sortedEvents = Event.events(configuration: self.configuration)?.sorted(byProperty: "timestamp") else {
guard let sortedEvents = Event.events(configuration: self.configuration)?.sorted(byKeyPath: #keyPath(Event.timestamp)) else {
completion?(.databaseUnavailable)
return
}
Expand Down
5 changes: 5 additions & 0 deletions Tests/DeviceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ final class DeviceTests: XCTestCase {
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()

Device.Cached.deviceIdentifier = ""
Device.Cached.systemName = ""
Device.Cached.systemVersion = ""
Device.Cached.deviceModel = ""
}

// MARK: deviceIdentifier
Expand Down
3 changes: 1 addition & 2 deletions Tests/TreasureDataTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import XCTest
final class TreasureDataTests: XCTestCase {
override func setUp() {
super.setUp()

let configuration = Configuration(
key: "KEY", database: "DATABASE", table: "TABLE", inMemoryIdentifier: "inMemoryIdentifier")
key: "KEY", database: "DATABASE", table: "TABLE", inMemoryIdentifier: name!)
TreasureData.configure(configuration)
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/UploadRequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class UploadRequestTests: XCTestCase {
key: "KEY",
database: "DATABASE",
table: "TABLE",
inMemoryIdentifier: "inMemoryIdentifier",
inMemoryIdentifier: name!,
shouldAppendDeviceIdentifier: true,
shouldAppendModelInformation: true,
shouldAppendSeverSideTimestamp: true,
Expand Down
6 changes: 3 additions & 3 deletions Tests/UploaderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class UploaderTests: XCTestCase {
key: "KEY",
database: "DATABASE",
table: "TABLE",
inMemoryIdentifier: "inMemoryIdentifier")
inMemoryIdentifier: name!)
let instance = TreasureData(configuration: configuration)
let event = Event().appendInformation(instance)
let stub = URLSessionStub()
Expand All @@ -45,7 +45,7 @@ final class UploaderTests: XCTestCase {
key: "KEY",
database: "DATABASE",
table: "TABLE",
inMemoryIdentifier: "inMemoryIdentifier")
inMemoryIdentifier: name!)
let instance = TreasureData(configuration: configuration)
let event = Event().appendInformation(instance)

Expand All @@ -65,7 +65,7 @@ final class UploaderTests: XCTestCase {
key: "KEY",
database: "DATABASE",
table: "TABLE",
inMemoryIdentifier: "inMemoryIdentifier",
inMemoryIdentifier: name!,
numberOfEventsEachRetryUploading: 2)
let instance = TreasureData(configuration: configuration)
let event1 = Event().appendInformation(instance)
Expand Down

0 comments on commit 91a2910

Please sign in to comment.