Skip to content

Commit

Permalink
Sync tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Pietro Caselani committed Jan 1, 2020
1 parent df01a78 commit 29bab70
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 930 deletions.
2 changes: 1 addition & 1 deletion CouchTrackerSync/CouchTrackerSync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func startSync(options: SyncOptions) -> Observable<BaseShow> {
}

private func syncMain(_ options: SyncOptions) -> Observable<BaseShow> {
return Current.syncWatchedShows(.full)
return Current.syncWatchedShows([.full, .noSeasons])
.flatMap { Observable.from($0) }
.flatMap { watchedProgress(options: options.watchedProgress, baseShow: $0) }
}
Expand Down
4 changes: 2 additions & 2 deletions CouchTrackerSync/SyncEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let traktBuilder = TraktBuilder {
private let trakt = Trakt(builder: traktBuilder)

struct SyncEnvironment {
var syncWatchedShows: (Extended) -> Observable<[BaseShow]>
var syncWatchedShows: ([Extended]) -> Observable<[BaseShow]>
var watchedProgress: (WatchedProgressOptions, ShowIds) -> Observable<BaseShow>
}

Expand All @@ -25,7 +25,7 @@ var Current = SyncEnvironment.live
let Current = SyncEnvironment.live
#endif

private func syncWatchedShows(extended: Extended) -> Observable<[BaseShow]> {
private func syncWatchedShows(extended: [Extended]) -> Observable<[BaseShow]> {
return trakt.sync.rx.request(.watched(type: .shows, extended: extended)).map([BaseShow].self).asObservable()
}

Expand Down
13 changes: 5 additions & 8 deletions CouchTrackerSyncTests/CouchTrackerSyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@ final class CouchTrackerSyncTests: XCTestCase {
}

func testSync() {
Current.syncWatchedShows = { _ in
Observable.just(decode(file: "syncWatchedShows-Success", as: [BaseShow].self))
Current.syncWatchedShows = { extended in
XCTAssertEqual(extended, [.full, .noSeasons])
return Observable.just(decode(file: "syncWatchedShows-Success", as: [BaseShow].self))
}

Current.watchedProgress = { _, _ in
Observable.just(decode(file: "watchedProgress-Success", as: BaseShow.self))
}

let expectedShows = decode(file: "baseShow-Success", as: BaseShow.self)

let observable = startSync(options: SyncOptions())

expect(observable)
expect(startSync(options: SyncOptions()))
.events(scheduler: scheduler, disposeBag: disposeBag)
.to(equal([
Recorded.next(0, expectedShows),
Recorded.next(0, decode(file: "baseShow-Success", as: BaseShow.self)),
Recorded.completed(0)
]))
}
Expand Down
Loading

0 comments on commit 29bab70

Please sign in to comment.