Skip to content

Commit

Permalink
Move TVDBSwift to CouchTracker repository
Browse files Browse the repository at this point in the history
  • Loading branch information
pietrocaselani committed May 17, 2019
1 parent 3940de6 commit 86fc67a
Show file tree
Hide file tree
Showing 48 changed files with 2,610 additions and 675 deletions.
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ excluded:
- vendor
- CouchTrackerCoreTests
- TraktSwiftTests
- TraktSwiftTestable
- TMDBSwiftTests
- TVDBSwiftTests
- CouchTrackerPlayground.playground

opt_in_rules:
Expand Down
1,522 changes: 985 additions & 537 deletions CouchTracker.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB32C8228CE000009A7C73"
BuildableName = "TVDBSwift.framework"
BlueprintName = "TVDBSwift-iOS"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB32C8228CE000009A7C73"
BuildableName = "TVDBSwift.framework"
BlueprintName = "TVDBSwift-iOS"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB32C8228CE000009A7C73"
BuildableName = "TVDBSwift.framework"
BlueprintName = "TVDBSwift-iOS"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
99 changes: 99 additions & 0 deletions CouchTracker.xcodeproj/xcshareddata/xcschemes/TVDBSwift.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB32AC228CDFEC009A7C73"
BuildableName = "TVDBSwift.framework"
BlueprintName = "TVDBSwift"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB3316228CE3F0009A7C73"
BuildableName = "TVDBSwiftTests.xctest"
BlueprintName = "TVDBSwiftTests"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB32AC228CDFEC009A7C73"
BuildableName = "TVDBSwift.framework"
BlueprintName = "TVDBSwift"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB32AC228CDFEC009A7C73"
BuildableName = "TVDBSwift.framework"
BlueprintName = "TVDBSwift"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB32AC228CDFEC009A7C73"
BuildableName = "TVDBSwift.framework"
BlueprintName = "TVDBSwift"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB3303228CE33C009A7C73"
BuildableName = "TVDBSwiftTestable.framework"
BlueprintName = "TVDBSwiftTestable"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB3303228CE33C009A7C73"
BuildableName = "TVDBSwiftTestable.framework"
BlueprintName = "TVDBSwiftTestable"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82EB3303228CE33C009A7C73"
BuildableName = "TVDBSwiftTestable.framework"
BlueprintName = "TVDBSwiftTestable"
ReferencedContainer = "container:CouchTracker.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
3 changes: 2 additions & 1 deletion CouchTrackerCore/Images/EpisodeImageUtils.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
import TVDBSwift

enum EpisodeImageUtils {
Expand All @@ -8,7 +9,7 @@ enum EpisodeImageUtils {
static func cacheKey(episode: EpisodeImageInput, size: EpisodeImageSizes?) -> Int {
var hasher = Hasher()
hasher.combine(HashableEpisodeImageInput(episode))
size.run { hasher.combine($0) }
hasher.combine(size)
return hasher.finalize()
}
}
5 changes: 2 additions & 3 deletions CouchTrackerCoreTests/Extensions/WatchedShowEntity+Mock.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import CouchTrackerCore

extension WatchedShowEntity {
static func mockEndedAndCompleted(decoder: JSONDecoder = .init()) -> WatchedShowEntity {
let data = Fixtures.WatchedShowEntity.jsonDataFor(file: "ended_completed")
return try! decoder.decode(WatchedShowEntity.self, from: data)
static func mockEndedAndCompleted() -> WatchedShowEntity {
return TraktEntitiesMock.endedAndCompletedShow()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ final class EpisodeImageCachedRepositoryTest: XCTestCase {
}

// Then
let expectedURL = URL(validURL: "https://www.thetvdb.com/banners/episodes/121361/3254641.jpg")
let expectedURL = URL(validURL: "https://www.thetvdb.com/banners/episodes/276564/5634087.jpg")

let expectedEvents = [Recorded.next(200, expectedURL), Recorded.completed(200)]

Expand Down
6 changes: 4 additions & 2 deletions CouchTrackerCoreTests/Show/Episode/ShowEpisodeMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,17 @@ final class ShowEpisodeMocks {
func addToHistory(items _: SyncItems) -> Single<SyncResponse> {
addToHistoryInvoked = true
return Single.deferred { () -> Single<SyncResponse> in
let syncResponse: SyncResponse = TraktEntitiesMock.decodeTraktJSON(with: "trakt_sync_addtohistory")
let addToHistoryData = Sync.addToHistory(items: SyncItems()).sampleData
let syncResponse = try JSONDecoder().decode(SyncResponse.self, from: addToHistoryData)
return Single.just(syncResponse)
}
}

func removeFromHistory(items _: SyncItems) -> Single<SyncResponse> {
removeFromHistoryInvoked = true
return Single.deferred { () -> Single<SyncResponse> in
let syncResponse: SyncResponse = TraktEntitiesMock.decodeTraktJSON(with: "trakt_sync_removefromhistory")
let removeFromHistoryData = Sync.removeFromHistory(items: SyncItems()).sampleData
let syncResponse = try JSONDecoder().decode(SyncResponse.self, from: removeFromHistoryData)
return Single.just(syncResponse)
}
}
Expand Down
47 changes: 6 additions & 41 deletions CouchTrackerCoreTests/TraktEntitiesMock.swift
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
import CouchTrackerCore
import TraktSwift
import TraktSwiftTestable

final class TraktEntitiesMock {
static func decodeTraktJSON<T: Codable>(with name: String) -> T {
let data = traktDataForJSON(with: name)
return try! jsonDecoder.decode(T.self, from: data)
}

static func decodeTraktJSONArray<T: Codable>(with name: String) -> [T] {
let data = traktDataForJSON(with: name)
return try! jsonDecoder.decode([T].self, from: data)
}

static func traktDataForJSON(with name: String) -> Data {
let resourcesPath = Bundle(for: Trakt.self).bundlePath

let bundle = findBundleUsing(resourcesPath: resourcesPath)

let url = bundle.url(forResource: name, withExtension: "json")

guard let fileURL = url, let data = try? Data(contentsOf: fileURL) else {
return Data()
}

return data
}

static var jsonDecoder: JSONDecoder {
return JSONDecoder()
}
Expand Down Expand Up @@ -88,8 +65,11 @@ final class TraktEntitiesMock {
}

static func createUnwatchedMovieDetailsMock() -> Movie {
let data = traktDataForJSON(with: "trakt_unwatched_movie_summary")
return try! jsonDecoder.decode(Movie.self, from: data)
return try! TraktTestableBundle.decode(resource: "trakt_unwatched_movie_summary")!
}

static func endedAndCompletedShow() -> WatchedShowEntity {
return try! TraktTestableBundle.decode(resource: "trakt_show_ended_completed")!
}

static func createMovieDetailsMock() -> Movie {
Expand All @@ -103,19 +83,4 @@ final class TraktEntitiesMock {
static func createUserSettingsMock() -> Settings {
return try! jsonDecoder.decode(Settings.self, from: Users.settings.sampleData)
}

private static func findBundleUsing(resourcesPath: String) -> Bundle {
var path = "/../"

var bundle: Bundle?
var attempt = 0

repeat {
bundle = Bundle(path: resourcesPath.appending("\(path)TraktTestsResources.bundle"))
path.append("../")
attempt += 1
} while bundle == nil && attempt < 5

return bundle!
}
}
Loading

0 comments on commit 86fc67a

Please sign in to comment.