diff --git a/Tentacle.xcodeproj/project.pbxproj b/Tentacle.xcodeproj/project.pbxproj index 9bf7432..17b114c 100644 --- a/Tentacle.xcodeproj/project.pbxproj +++ b/Tentacle.xcodeproj/project.pbxproj @@ -69,6 +69,10 @@ BE88E84D1C88E6D60034A112 /* Argo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE88E84B1C88E6D60034A112 /* Argo.framework */; }; BE88E84E1C88E6D60034A112 /* Curry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE88E84C1C88E6D60034A112 /* Curry.framework */; }; BE88E8751C88F0C50034A112 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE88E8741C88F0C50034A112 /* main.swift */; }; + BEA86F9A1C9F7C230049360B /* ServerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA86F991C9F7C230049360B /* ServerTests.swift */; }; + BEA86F9B1C9F7C230049360B /* ServerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA86F991C9F7C230049360B /* ServerTests.swift */; }; + BEA86F9D1C9F7E1E0049360B /* RepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA86F9C1C9F7E1E0049360B /* RepositoryTests.swift */; }; + BEA86F9E1C9F7E1E0049360B /* RepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA86F9C1C9F7E1E0049360B /* RepositoryTests.swift */; }; BEAB175B1C9D0AB7009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.data in Resources */ = {isa = PBXBuildFile; fileRef = BEAB17571C9D062D009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.data */; }; BEAB175C1C9D0AB7009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.response in Resources */ = {isa = PBXBuildFile; fileRef = BEAB17581C9D062D009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.response */; }; BEAB175D1C9D0AB8009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.data in Resources */ = {isa = PBXBuildFile; fileRef = BEAB17571C9D062D009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.data */; }; @@ -142,6 +146,8 @@ BE88E8671C88F0990034A112 /* update-test-fixtures.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "update-test-fixtures.app"; sourceTree = BUILT_PRODUCTS_DIR; }; BE88E8701C88F0990034A112 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; BE88E8741C88F0C50034A112 /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + BEA86F991C9F7C230049360B /* ServerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServerTests.swift; sourceTree = ""; }; + BEA86F9C1C9F7E1E0049360B /* RepositoryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryTests.swift; sourceTree = ""; }; BEAB17571C9D062D009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.data */ = {isa = PBXFileReference; lastKnownFileType = file; path = "repos-mdiep-MDPSplitView-releases-assets-433845.data"; sourceTree = ""; }; BEAB17581C9D062D009F8F58 /* repos-mdiep-MDPSplitView-releases-assets-433845.response */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = "repos-mdiep-MDPSplitView-releases-assets-433845.response"; sourceTree = ""; }; BEB0765C1C8A001C00ABD373 /* GitHubError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitHubError.swift; sourceTree = ""; }; @@ -274,7 +280,9 @@ BE2B6A6B1C8B854F0080BFEB /* ClientTests.swift */, BEB0765E1C8A019A00ABD373 /* GitHubErrorTests.swift */, BE0F40A11C8909EB00E3B11A /* ReleaseTests.swift */, + BEA86F9C1C9F7E1E0049360B /* RepositoryTests.swift */, BE1E036A1C9AD87F001296C2 /* ResponseTests.swift */, + BEA86F991C9F7C230049360B /* ServerTests.swift */, BE88E8031C88C6B30034A112 /* Info.plist */, ); path = Tests; @@ -556,6 +564,8 @@ files = ( 619081881C8A2DB7001BE2F8 /* Fixture.swift in Sources */, BE2B6A6D1C8B854F0080BFEB /* ClientTests.swift in Sources */, + BEA86F9B1C9F7C230049360B /* ServerTests.swift in Sources */, + BEA86F9E1C9F7E1E0049360B /* RepositoryTests.swift in Sources */, 6190818B1C8A2DB7001BE2F8 /* (null) in Sources */, 619081891C8A2DB7001BE2F8 /* GitHubErrorTests.swift in Sources */, BE1E036C1C9AD87F001296C2 /* ResponseTests.swift in Sources */, @@ -584,9 +594,11 @@ buildActionMask = 2147483647; files = ( BE1E036B1C9AD87F001296C2 /* ResponseTests.swift in Sources */, + BEA86F9D1C9F7E1E0049360B /* RepositoryTests.swift in Sources */, BEB076601C8A019E00ABD373 /* GitHubErrorTests.swift in Sources */, BE0F40A01C89098E00E3B11A /* Fixture.swift in Sources */, BE2B6A6C1C8B854F0080BFEB /* ClientTests.swift in Sources */, + BEA86F9A1C9F7C230049360B /* ServerTests.swift in Sources */, BE0F40A21C8909EB00E3B11A /* ReleaseTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Tentacle/Repository.swift b/Tentacle/Repository.swift index 7b91f49..5372e46 100644 --- a/Tentacle/Repository.swift +++ b/Tentacle/Repository.swift @@ -29,7 +29,7 @@ public struct Repository: Hashable, CustomStringConvertible { } public var hashValue: Int { - return URL.hashValue + return description.lowercaseString.hashValue } public var description: String { @@ -39,6 +39,6 @@ public struct Repository: Hashable, CustomStringConvertible { public func ==(lhs: Repository, rhs: Repository) -> Bool { return lhs.server == rhs.server - && lhs.owner == rhs.owner - && lhs.name == rhs.name + && lhs.owner.caseInsensitiveCompare(rhs.owner) == .OrderedSame + && lhs.name.caseInsensitiveCompare(rhs.name) == .OrderedSame } diff --git a/Tentacle/Server.swift b/Tentacle/Server.swift index e51aa4f..5cba5fa 100644 --- a/Tentacle/Server.swift +++ b/Tentacle/Server.swift @@ -39,7 +39,7 @@ public enum Server: Hashable, CustomStringConvertible { } public var hashValue: Int { - return endpoint.hashValue + return endpoint.lowercaseString.hashValue } public var description: String { @@ -52,8 +52,8 @@ public func ==(lhs: Server, rhs: Server) -> Bool { case (.DotCom, .DotCom): return true - case let (.Enterprise(URL1), .Enterprise(URL2)): - return URL1 == URL2 + case (.Enterprise, .Enterprise): + return lhs.endpoint.caseInsensitiveCompare(rhs.endpoint) == .OrderedSame default: return false diff --git a/Tests/RepositoryTests.swift b/Tests/RepositoryTests.swift new file mode 100644 index 0000000..57f026c --- /dev/null +++ b/Tests/RepositoryTests.swift @@ -0,0 +1,22 @@ +// +// RepositoryTests.swift +// Tentacle +// +// Created by Matt Diephouse on 3/20/16. +// Copyright © 2016 Matt Diephouse. All rights reserved. +// + +import Tentacle +import XCTest + +class RepositoryTests: XCTestCase { + func testEquality() { + let repo1 = Repository(owner: "mdiep", name: "Tentacle") + let repo2 = Repository(owner: "mdiep", name: "TENTACLE") + let repo3 = Repository(owner: "MDIEP", name: "Tentacle") + XCTAssertEqual(repo1, repo2) + XCTAssertEqual(repo1, repo3) + XCTAssertEqual(repo1.hashValue, repo2.hashValue) + XCTAssertEqual(repo1.hashValue, repo3.hashValue) + } +} diff --git a/Tests/ServerTests.swift b/Tests/ServerTests.swift new file mode 100644 index 0000000..1f92585 --- /dev/null +++ b/Tests/ServerTests.swift @@ -0,0 +1,19 @@ +// +// ServerTests.swift +// Tentacle +// +// Created by Matt Diephouse on 3/20/16. +// Copyright © 2016 Matt Diephouse. All rights reserved. +// + +import Tentacle +import XCTest + +class ServerTests: XCTestCase { + func testEquality() { + let server1 = Server.Enterprise(url: NSURL(string: "https://example.com")!) + let server2 = Server.Enterprise(url: NSURL(string: "https://EXAMPLE.COM")!) + XCTAssertEqual(server1, server2) + XCTAssertEqual(server1.hashValue, server2.hashValue) + } +}