Skip to content

Commit

Permalink
Add test for the Endpoint enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Palleas committed Feb 5, 2017
1 parent 6cf6ac9 commit c7b5c7c
Show file tree
Hide file tree
Showing 11 changed files with 341 additions and 144 deletions.
340 changes: 197 additions & 143 deletions Tentacle.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Tentacle/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ public final class Client {

internal var queryItems: [URLQueryItem] {
switch self {
case let .content(_, _, _, ref): return [URLQueryItem(name: "ref", value: ref)]
case let .content(_, _, _, ref):
return [ref]
.flatMap { $0 }
.map { URLQueryItem(name: "ref", value: $0) }
default: return []
}
}
Expand Down
22 changes: 22 additions & 0 deletions Tests/EndpointTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// EndpointTests.swift
// Tentacle
//
// Created by Romain Pouclet on 2017-02-05.
// Copyright © 2017 Matt Diephouse. All rights reserved.
//

import XCTest
@testable import Tentacle

class EndpointTests: XCTestCase {

func testEndpointProvidesQueryItemsWhenNeeded() {
let endpoint: Client.Endpoint = .content(owner: "palleas", repository: "romain-pouclet.com", path: "config.yml", ref: "sample-branch")
XCTAssertEqual([URLQueryItem(name: "ref", value: "sample-branch")], endpoint.queryItems)

let endpointWithoutRef: Client.Endpoint = .content(owner: "palleas", repository: "romain-pouclet.com", path: "config.yml", ref: nil)
XCTAssertEqual(0, endpointWithoutRef.queryItems.count)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"encoding" : "base64",
"download_url" : "https:\/\/raw.githubusercontent.com\/Palleas-opensource\/Sample-repository\/master\/README.md",
"url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/README.md?ref=master",
"path" : "README.md",
"size" : 19,
"type" : "file",
"git_url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/git\/blobs\/28ec72028c4ae47de689964a23ebb223f10cfe80",
"html_url" : "https:\/\/github.com\/Palleas-opensource\/Sample-repository\/blob\/master\/README.md",
"_links" : {
"git" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/git\/blobs\/28ec72028c4ae47de689964a23ebb223f10cfe80",
"html" : "https:\/\/github.com\/Palleas-opensource\/Sample-repository\/blob\/master\/README.md",
"self" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/README.md?ref=master"
},
"sha" : "28ec72028c4ae47de689964a23ebb223f10cfe80",
"name" : "README.md",
"content" : "IyBTYW1wbGUtcmVwb3NpdG9yeQ==\n"
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"target" : "\/usr\/bin\/say",
"git_url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/git\/blobs\/1e3f1fd0bc1f65cf4701c217f4d1fd9a3cd50721",
"_links" : {
"git" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/git\/blobs\/1e3f1fd0bc1f65cf4701c217f4d1fd9a3cd50721",
"html" : "https:\/\/github.com\/Palleas-opensource\/Sample-repository\/blob\/master\/Tools\/say",
"self" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/Tools\/say?ref=master"
},
"html_url" : "https:\/\/github.com\/Palleas-opensource\/Sample-repository\/blob\/master\/Tools\/say",
"download_url" : "https:\/\/raw.githubusercontent.com\/Palleas-opensource\/Sample-repository\/master\/Tools\/say",
"size" : 12,
"sha" : "1e3f1fd0bc1f65cf4701c217f4d1fd9a3cd50721",
"path" : "Tools\/say",
"type" : "symlink",
"name" : "say",
"url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/Tools\/say?ref=master"
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[
{
"_links" : {
"git" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/git\/trees\/5bfad2b3f8e483b6b173d8aaff19597e84626f15",
"html" : "https:\/\/github.com\/Palleas-opensource\/Sample-repository\/tree\/master\/Tools\/Directory",
"self" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/Tools\/Directory?ref=master"
},
"git_url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/git\/trees\/5bfad2b3f8e483b6b173d8aaff19597e84626f15",
"html_url" : "https:\/\/github.com\/Palleas-opensource\/Sample-repository\/tree\/master\/Tools\/Directory",
"download_url" : null,
"size" : 0,
"sha" : "5bfad2b3f8e483b6b173d8aaff19597e84626f15",
"path" : "Tools\/Directory",
"type" : "dir",
"name" : "Directory",
"url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/Tools\/Directory?ref=master"
},
{
"_links" : {
"git" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/git\/blobs\/c3eb8708a0a5aaa4f685aab24ef6403fbfd28efc",
"html" : "https:\/\/github.com\/Palleas-opensource\/Sample-repository\/blob\/master\/Tools\/README.markdown",
"self" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/Tools\/README.markdown?ref=master"
},
"git_url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/git\/blobs\/c3eb8708a0a5aaa4f685aab24ef6403fbfd28efc",
"html_url" : "https:\/\/github.com\/Palleas-opensource\/Sample-repository\/blob\/master\/Tools\/README.markdown",
"download_url" : "https:\/\/raw.githubusercontent.com\/Palleas-opensource\/Sample-repository\/master\/Tools\/README.markdown",
"size" : 18,
"sha" : "c3eb8708a0a5aaa4f685aab24ef6403fbfd28efc",
"path" : "Tools\/README.markdown",
"type" : "file",
"name" : "README.markdown",
"url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/Tools\/README.markdown?ref=master"
},
{
"_links" : {
"git" : "https:\/\/api.github.com\/repos\/mdiep\/Tentacle\/git\/trees\/7a84505a3c553fd8e2879cfa63753b0cd212feb8",
"html" : "https:\/\/github.com\/mdiep\/Tentacle\/tree\/7a84505a3c553fd8e2879cfa63753b0cd212feb8",
"self" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/Tools\/Tentacle?ref=master"
},
"git_url" : "https:\/\/api.github.com\/repos\/mdiep\/Tentacle\/git\/trees\/7a84505a3c553fd8e2879cfa63753b0cd212feb8",
"html_url" : "https:\/\/github.com\/mdiep\/Tentacle\/tree\/7a84505a3c553fd8e2879cfa63753b0cd212feb8",
"download_url" : null,
"size" : 0,
"sha" : "7a84505a3c553fd8e2879cfa63753b0cd212feb8",
"path" : "Tools\/Tentacle",
"type" : "file",
"name" : "Tentacle",
"url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/Tools\/Tentacle?ref=master"
},
{
"_links" : {
"git" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/git\/blobs\/1e3f1fd0bc1f65cf4701c217f4d1fd9a3cd50721",
"html" : "https:\/\/github.com\/Palleas-opensource\/Sample-repository\/blob\/master\/Tools\/say",
"self" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/Tools\/say?ref=master"
},
"git_url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/git\/blobs\/1e3f1fd0bc1f65cf4701c217f4d1fd9a3cd50721",
"html_url" : "https:\/\/github.com\/Palleas-opensource\/Sample-repository\/blob\/master\/Tools\/say",
"download_url" : "https:\/\/raw.githubusercontent.com\/Palleas-opensource\/Sample-repository\/master\/Tools\/say",
"size" : 12,
"sha" : "1e3f1fd0bc1f65cf4701c217f4d1fd9a3cd50721",
"path" : "Tools\/say",
"type" : "symlink",
"name" : "say",
"url" : "https:\/\/api.github.com\/repos\/Palleas-opensource\/Sample-repository\/contents\/Tools\/say?ref=master"
}
]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"_links" : {
"git" : "https:\/\/api.github.com\/repos\/ReactiveCocoa\/ReactiveSwift\/git\/trees\/7920f196fd5073f4c98e03fa40b4e4b72470b935",
"html" : "https:\/\/github.com\/ReactiveCocoa\/ReactiveSwift\/tree\/7920f196fd5073f4c98e03fa40b4e4b72470b935",
"self" : "https:\/\/api.github.com\/repos\/mdiep\/Tentacle\/contents\/Carthage\/Checkouts\/ReactiveSwift?ref=master"
},
"git_url" : "https:\/\/api.github.com\/repos\/ReactiveCocoa\/ReactiveSwift\/git\/trees\/7920f196fd5073f4c98e03fa40b4e4b72470b935",
"html_url" : "https:\/\/github.com\/ReactiveCocoa\/ReactiveSwift\/tree\/7920f196fd5073f4c98e03fa40b4e4b72470b935",
"download_url" : null,
"size" : 0,
"submodule_git_url" : "https:\/\/github.com\/ReactiveCocoa\/ReactiveSwift.git",
"sha" : "7920f196fd5073f4c98e03fa40b4e4b72470b935",
"path" : "Carthage\/Checkouts\/ReactiveSwift",
"type" : "submodule",
"name" : "ReactiveSwift",
"url" : "https:\/\/api.github.com\/repos\/mdiep\/Tentacle\/contents\/Carthage\/Checkouts\/ReactiveSwift?ref=master"
}
Binary file not shown.

0 comments on commit c7b5c7c

Please sign in to comment.