Skip to content

Commit

Permalink
Add Issues model objects and setup test
Browse files Browse the repository at this point in the history
  • Loading branch information
Palleas committed May 24, 2016
1 parent 8431308 commit 183fc12
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Tentacle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
619081891C8A2DB7001BE2F8 /* GitHubErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB0765E1C8A019A00ABD373 /* GitHubErrorTests.swift */; };
6190818A1C8A2DB7001BE2F8 /* ReleaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0F40A11C8909EB00E3B11A /* ReleaseTests.swift */; };
6190818B1C8A2DB7001BE2F8 /* (null) in Sources */ = {isa = PBXBuildFile; };
7A1A82561CF3DBAC0076E2DD /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1A82551CF3DBAC0076E2DD /* Issue.swift */; };
7A1A82581CF3DE4C0076E2DD /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1A82571CF3DE4C0076E2DD /* Label.swift */; };
7A1A825A1CF3DEEA0076E2DD /* Milestone.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1A82591CF3DEEA0076E2DD /* Milestone.swift */; };
7A1A825C1CF3E1820076E2DD /* IssuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1A825B1CF3E1820076E2DD /* IssuesTests.swift */; };
BE0F40A01C89098E00E3B11A /* Fixture.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0F409F1C89098E00E3B11A /* Fixture.swift */; };
BE0F40A21C8909EB00E3B11A /* ReleaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0F40A11C8909EB00E3B11A /* ReleaseTests.swift */; };
BE0F40A41C89135D00E3B11A /* Decodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0F40A31C89135D00E3B11A /* Decodable.swift */; };
Expand Down Expand Up @@ -121,6 +125,10 @@
/* Begin PBXFileReference section */
61377C6C1C8A2B2C0081FF24 /* Tentacle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Tentacle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6190817D1C8A2D2B001BE2F8 /* Tentacle-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Tentacle-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
7A1A82551CF3DBAC0076E2DD /* Issue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Issue.swift; sourceTree = "<group>"; };
7A1A82571CF3DE4C0076E2DD /* Label.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
7A1A82591CF3DEEA0076E2DD /* Milestone.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Milestone.swift; sourceTree = "<group>"; };
7A1A825B1CF3E1820076E2DD /* IssuesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssuesTests.swift; sourceTree = "<group>"; };
BE0F409F1C89098E00E3B11A /* Fixture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Fixture.swift; path = Tests/Fixture.swift; sourceTree = SOURCE_ROOT; };
BE0F40A11C8909EB00E3B11A /* ReleaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReleaseTests.swift; sourceTree = "<group>"; };
BE0F40A31C89135D00E3B11A /* Decodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decodable.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -295,6 +303,9 @@
BE88E82C1C88C94D0034A112 /* Server.swift */,
BECB8A8A1CBDCD17005D70A6 /* User.swift */,
BE88E7F71C88C6B30034A112 /* Info.plist */,
7A1A82551CF3DBAC0076E2DD /* Issue.swift */,
7A1A82571CF3DE4C0076E2DD /* Label.swift */,
7A1A82591CF3DEEA0076E2DD /* Milestone.swift */,
);
path = Tentacle;
sourceTree = "<group>";
Expand All @@ -312,6 +323,7 @@
BEA86F991C9F7C230049360B /* ServerTests.swift */,
BECB8AA11CBDDF0F005D70A6 /* UserTests.swift */,
BE88E8031C88C6B30034A112 /* Info.plist */,
7A1A825B1CF3E1820076E2DD /* IssuesTests.swift */,
);
path = Tests;
sourceTree = "<group>";
Expand Down Expand Up @@ -621,19 +633,23 @@
BEEE47421C91B8DF000FFC21 /* ResourceType.swift in Sources */,
BEB0765D1C8A001C00ABD373 /* GitHubError.swift in Sources */,
BEEE474E1C92623E000FFC21 /* Response.swift in Sources */,
7A1A82581CF3DE4C0076E2DD /* Label.swift in Sources */,
7A1A825A1CF3DEEA0076E2DD /* Milestone.swift in Sources */,
BE88E8321C88D33D0034A112 /* Release.swift in Sources */,
BE88E80D1C88C72B0034A112 /* Client.swift in Sources */,
BE0F40A41C89135D00E3B11A /* Decodable.swift in Sources */,
BECB8A8B1CBDCD17005D70A6 /* User.swift in Sources */,
BECB8A8E1CBDD919005D70A6 /* FoundationExtensions.swift in Sources */,
BE88E8301C88CDAB0034A112 /* Repository.swift in Sources */,
7A1A82561CF3DBAC0076E2DD /* Issue.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
BE88E7F81C88C6B30034A112 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7A1A825C1CF3E1820076E2DD /* IssuesTests.swift in Sources */,
BE1E036B1C9AD87F001296C2 /* ResponseTests.swift in Sources */,
BEA86F9D1C9F7E1E0049360B /* RepositoryTests.swift in Sources */,
BEB076601C8A019E00ABD373 /* GitHubErrorTests.swift in Sources */,
Expand Down
7 changes: 7 additions & 0 deletions Tentacle/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ public final class Client {

// https://developer.github.com/v3/users/#get-a-single-user
case User(login: String)

// https://developer.github.com/v3/issues/#list-issues
case Issues

var path: String {
switch self {
Expand All @@ -170,6 +173,8 @@ public final class Client {
return "/repos/\(owner)/\(repo)/releases"
case let .User(login):
return "/users/\(login)"
case .Issues:
return "/issues"
}
}

Expand All @@ -181,6 +186,8 @@ public final class Client {
return owner.hashValue ^ repo.hashValue
case let .User(login):
return login.hashValue
case .Issues:
return "Issues".hashValue
}
}

Expand Down
42 changes: 42 additions & 0 deletions Tentacle/Issue.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// Issue.swift
// Tentacle
//
// Created by Romain Pouclet on 2016-05-23.
// Copyright © 2016 Matt Diephouse. All rights reserved.
//

import UIKit

/// An Issue on Github
public struct Issue: Hashable, CustomStringConvertible {
enum State {
case Open
case Closed
}

public let id: Int
public let url: NSURL

public repositoryUrl: NSURL
public labelsUrl: NSURL
public commentsUrl: NSURL
public eventsUrl: NSURL
public htmlUrl: NSURL

public let number: Int
public let state: State
public let title: String
public let body: String
public let user: User,
public let labels: [Label]
public let assignee: User?
public let milestone: Milestone?

public let locked: Bool
public let comments: Int
public let pullRequest: PullRequest?
public let closedAt: NSDate?
public let createdAt: NSDate
public let updatedAt: NSDate
}
15 changes: 15 additions & 0 deletions Tentacle/Label.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Label.swift
// Tentacle
//
// Created by Romain Pouclet on 2016-05-23.
// Copyright © 2016 Matt Diephouse. All rights reserved.
//

import Foundation

struct Label: Hashable, CustomStringConvertible {
let URL: NSURL
let name: String
let color: String
}
33 changes: 33 additions & 0 deletions Tentacle/Milestone.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Milestone.swift
// Tentacle
//
// Created by Romain Pouclet on 2016-05-23.
// Copyright © 2016 Matt Diephouse. All rights reserved.
//

import Foundation

public struct Milestone: Hashable, CustomStringConvertible {
enum State {
case Open
case Closed
}

public let URL: NSURL
public let htmlURL: NSURL
public let labelsURL: NSURL
public let id: Int
public let number: Int
public let state: State
public let title: String
public let description: String
public let creator User
public let openIssues: Int
public let closedIssues: Int
public let createdAt: NSDate
public let updatedAt: NSDate
public let closedAt: NSDate?
public let dueOn: NSDate

}
16 changes: 16 additions & 0 deletions Tests/Fixture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,20 @@ struct Fixture {
self.login = login
}
}

struct Issues: EndpointFixtureType {
let server: Server

var endpoint: Client.Endpoint {
return .Issues
}

let page: UInt? = nil
let pageSize: UInt? = nil
let contentType = Client.APIContentType

init(_ server: Server) {
self.server = server
}
}
}
18 changes: 18 additions & 0 deletions Tests/IssuesTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// IssuesTests.swift
// Tentacle
//
// Created by Romain Pouclet on 2016-05-23.
// Copyright © 2016 Matt Diephouse. All rights reserved.
//

import Argo
@testable import Tentacle
import XCTest

class IssuesTests: XCTestCase {

func testDecodeIssues() {

}
}

0 comments on commit 183fc12

Please sign in to comment.