ran swiftlint
This commit is contained in:
parent
fd055faf61
commit
6e6a8af44e
|
@ -17,13 +17,13 @@ let package = Package(
|
|||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
.package(name: "Buildkite", path: "../"),
|
||||
.package(name: "Buildkite", path: "../")
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
|
||||
.target(
|
||||
name: "Example",
|
||||
dependencies: ["Buildkite"]),
|
||||
dependencies: ["Buildkite"])
|
||||
]
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ let package = Package(
|
|||
.iOS(.v10),
|
||||
.macOS(.v10_12),
|
||||
.tvOS(.v10),
|
||||
.watchOS(.v3),
|
||||
.watchOS(.v3)
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries produced by a package, and make them visible to other packages.
|
||||
|
@ -29,6 +29,6 @@ let package = Package(
|
|||
dependencies: []),
|
||||
.testTarget(
|
||||
name: "BuildkiteTests",
|
||||
dependencies: ["Buildkite"]),
|
||||
dependencies: ["Buildkite"])
|
||||
]
|
||||
)
|
||||
|
|
|
@ -19,17 +19,17 @@ public final class Buildkite {
|
|||
encoder.keyEncodingStrategy = .convertToSnakeCase
|
||||
return encoder
|
||||
}()
|
||||
|
||||
|
||||
let decoder: JSONDecoder = {
|
||||
let decoder = JSONDecoder()
|
||||
decoder.dateDecodingStrategy = .custom(Formatters.decodeISO8601)
|
||||
decoder.keyDecodingStrategy = .convertFromSnakeCase
|
||||
return decoder
|
||||
}()
|
||||
|
||||
|
||||
var configuration: Configuration
|
||||
var transport: Transport
|
||||
|
||||
|
||||
public var token: String? {
|
||||
get {
|
||||
configuration.token
|
||||
|
@ -38,22 +38,22 @@ public final class Buildkite {
|
|||
configuration.token = newValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public init(configuration: Configuration = .default, transport: Transport = URLSession.shared) {
|
||||
self.configuration = configuration
|
||||
self.transport = transport
|
||||
}
|
||||
|
||||
|
||||
public func send<R: Resource & HasResponseBody>(_ resource: R, completion: @escaping (Result<Response<R.Content>, Error>) -> Void) {
|
||||
let request = URLRequest(resource, configuration: configuration)
|
||||
transport.send(request: request, completion: handleContentfulResponse(completion: completion))
|
||||
}
|
||||
|
||||
|
||||
public func send<R: Resource & Paginated>(_ resource: R, pageOptions: PageOptions? = nil, completion: @escaping (Result<Response<R.Content>, Error>) -> Void) {
|
||||
let request = URLRequest(resource, configuration: configuration, pageOptions: pageOptions)
|
||||
transport.send(request: request, completion: handleContentfulResponse(completion: completion))
|
||||
}
|
||||
|
||||
|
||||
public func send<R: Resource & HasRequestBody & HasResponseBody>(_ resource: R, completion: @escaping (Result<Response<R.Content>, Error>) -> Void) {
|
||||
let request: URLRequest
|
||||
do {
|
||||
|
@ -64,7 +64,7 @@ public final class Buildkite {
|
|||
}
|
||||
transport.send(request: request, completion: handleContentfulResponse(completion: completion))
|
||||
}
|
||||
|
||||
|
||||
public func send<R: Resource & HasRequestBody & Paginated>(_ resource: R, pageOptions: PageOptions? = nil, completion: @escaping (Result<Response<R.Content>, Error>) -> Void) {
|
||||
let request: URLRequest
|
||||
do {
|
||||
|
@ -75,12 +75,12 @@ public final class Buildkite {
|
|||
}
|
||||
transport.send(request: request, completion: handleContentfulResponse(completion: completion))
|
||||
}
|
||||
|
||||
|
||||
public func send<R: Resource>(_ resource: R, completion: @escaping (Result<Response<Void>, Error>) -> Void) {
|
||||
let request = URLRequest(resource, configuration: configuration)
|
||||
transport.send(request: request, completion: handleEmptyResponse(completion: completion))
|
||||
}
|
||||
|
||||
|
||||
public func send<R: Resource & HasRequestBody>(_ resource: R, completion: @escaping (Result<Response<Void>, Error>) -> Void) {
|
||||
let request: URLRequest
|
||||
do {
|
||||
|
@ -91,7 +91,7 @@ public final class Buildkite {
|
|||
}
|
||||
transport.send(request: request, completion: handleEmptyResponse(completion: completion))
|
||||
}
|
||||
|
||||
|
||||
private func handleContentfulResponse<Content: Decodable>(completion: @escaping (Result<Response<Content>, Error>) -> Void) -> Transport.Completion {
|
||||
return { [weak self] result in
|
||||
guard let self = self else {
|
||||
|
@ -111,7 +111,7 @@ public final class Buildkite {
|
|||
completion(.success(Response(content: content, response: response)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func handleEmptyResponse(completion: @escaping (Result<Response<Void>, Error>) -> Void) -> Transport.Completion {
|
||||
return { [weak self] result in
|
||||
guard let self = self else {
|
||||
|
@ -128,7 +128,7 @@ public final class Buildkite {
|
|||
completion(.success(Response(content: (), response: response)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func checkResponseForIssues(_ response: URLResponse, data: Data? = nil) throws {
|
||||
guard let response = response as? HTTPURLResponse,
|
||||
let statusCode = StatusCode(rawValue: response.statusCode) else {
|
||||
|
@ -159,7 +159,7 @@ extension Buildkite {
|
|||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
|
||||
public func sendPublisher<R: Resource & HasResponseBody & Paginated>(_ resource: R, pageOptions: PageOptions? = nil) -> AnyPublisher<Response<R.Content>, Error> {
|
||||
transport.sendPublisher(request: URLRequest(resource, configuration: configuration, pageOptions: pageOptions))
|
||||
.tryMap {
|
||||
|
@ -169,7 +169,7 @@ extension Buildkite {
|
|||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
|
||||
public func sendPublisher<R: Resource & HasRequestBody & HasResponseBody>(_ resource: R) -> AnyPublisher<Response<R.Content>, Error> {
|
||||
Result { try URLRequest(resource, configuration: configuration, encoder: encoder) }
|
||||
.publisher
|
||||
|
@ -181,7 +181,7 @@ extension Buildkite {
|
|||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
|
||||
public func sendPublisher<R: Resource & HasRequestBody & Paginated>(_ resource: R, pageOptions: PageOptions? = nil) -> AnyPublisher<Response<R.Content>, Error> {
|
||||
Result { try URLRequest(resource, configuration: configuration, encoder: encoder, pageOptions: pageOptions) }
|
||||
.publisher
|
||||
|
@ -193,7 +193,7 @@ extension Buildkite {
|
|||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
|
||||
public func sendPublisher<R: Resource>(_ resource: R) -> AnyPublisher<Response<Void>, Error> {
|
||||
transport.sendPublisher(request: URLRequest(resource, configuration: configuration))
|
||||
.tryMap {
|
||||
|
@ -202,7 +202,7 @@ extension Buildkite {
|
|||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
|
||||
func sendPublisher<R: Resource & HasRequestBody>(_ resource: R) -> AnyPublisher<Response<Void>, Error> {
|
||||
Result { try URLRequest(resource, configuration: configuration, encoder: encoder) }
|
||||
.publisher
|
||||
|
|
|
@ -33,7 +33,7 @@ public struct Build: Codable, Equatable, Identifiable {
|
|||
public var metaData: [String: String]
|
||||
public var pullRequest: [String: String?]?
|
||||
public var pipeline: Pipeline
|
||||
|
||||
|
||||
public enum State: String, Codable, Equatable {
|
||||
case running
|
||||
case scheduled
|
||||
|
|
|
@ -17,14 +17,14 @@ public enum Job: Codable, Equatable {
|
|||
case waiter(Wait)
|
||||
case manual(Block)
|
||||
case trigger(Trigger)
|
||||
|
||||
|
||||
private enum Unassociated: String, Codable {
|
||||
case script
|
||||
case waiter
|
||||
case manual
|
||||
case trigger
|
||||
}
|
||||
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let type = try container.decode(Unassociated.self, forKey: .type)
|
||||
|
@ -39,7 +39,7 @@ public enum Job: Codable, Equatable {
|
|||
self = .trigger(try Trigger(from: decoder))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
switch self {
|
||||
case .script(let step):
|
||||
|
@ -52,11 +52,11 @@ public enum Job: Codable, Equatable {
|
|||
try step.encode(to: encoder)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case type
|
||||
}
|
||||
|
||||
|
||||
public struct Command: Codable, Equatable, Identifiable {
|
||||
public struct AgentRef: Codable, Equatable {
|
||||
public var id: UUID
|
||||
|
@ -89,12 +89,12 @@ public enum Job: Codable, Equatable {
|
|||
public var parallelGroupIndex: Int?
|
||||
public var parallelGroupTotal: Int?
|
||||
}
|
||||
|
||||
|
||||
public struct Wait: Codable, Equatable, Identifiable {
|
||||
public let type = "waiter"
|
||||
public var id: UUID
|
||||
}
|
||||
|
||||
|
||||
public struct Block: Codable, Equatable, Identifiable {
|
||||
public let type = "manual"
|
||||
public var id: UUID
|
||||
|
@ -106,7 +106,7 @@ public enum Job: Codable, Equatable {
|
|||
public var unblockable: Bool
|
||||
public var unblockUrl: URL
|
||||
}
|
||||
|
||||
|
||||
public struct Trigger: Codable, Equatable {
|
||||
public let type = "trigger"
|
||||
public var name: String
|
||||
|
@ -118,7 +118,7 @@ public enum Job: Codable, Equatable {
|
|||
public var finishedAt: Date?
|
||||
public var runnableAt: Date?
|
||||
public var triggeredBuild: TriggeredBuild
|
||||
|
||||
|
||||
public struct TriggeredBuild: Codable, Equatable, Identifiable {
|
||||
public var id: UUID
|
||||
public var number: Int
|
||||
|
@ -126,14 +126,14 @@ public enum Job: Codable, Equatable {
|
|||
public var webUrl: URL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public struct LogOutput: Codable, Equatable {
|
||||
public var url: URL // Resource<Job.Resources.GetLogOutput>
|
||||
public var content: String
|
||||
public var size: Int
|
||||
public var headerTimes: [Int]
|
||||
}
|
||||
|
||||
|
||||
public struct EnvironmentVariables: Codable, Equatable {
|
||||
public var env: [String: String]
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ public enum EnvVar: Codable, Equatable {
|
|||
case string(String)
|
||||
indirect case array([EnvVar])
|
||||
indirect case dictionary(EnvVars)
|
||||
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.singleValueContainer()
|
||||
|
||||
|
@ -202,10 +202,10 @@ public enum EnvVar: Codable, Equatable {
|
|||
self = .dictionary(dict)
|
||||
return
|
||||
} catch DecodingError.typeMismatch {}
|
||||
|
||||
|
||||
throw DecodingError.typeMismatch(Self.self, DecodingError.Context(codingPath: container.codingPath, debugDescription: "Expected to decode \(Self.self) but the value in the container was incompatible"))
|
||||
}
|
||||
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.singleValueContainer()
|
||||
switch self {
|
||||
|
|
|
@ -29,7 +29,7 @@ public struct Team: Codable, Equatable, Identifiable {
|
|||
public var createdAt: Date
|
||||
/// User who created the team
|
||||
public var createdBy: User
|
||||
|
||||
|
||||
public enum Visibility: String, Codable, Equatable {
|
||||
case visible
|
||||
case secret
|
||||
|
|
|
@ -23,13 +23,13 @@ enum Formatters {
|
|||
}
|
||||
return formatter
|
||||
}()
|
||||
|
||||
|
||||
static let iso8601WithoutFractionalSeconds: ISO8601DateFormatter = {
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime]
|
||||
return formatter
|
||||
}()
|
||||
|
||||
|
||||
static func dateIfPossible(fromISO8601 string: String) -> Date? {
|
||||
if let date = iso8601WithFractionalSeconds.date(from: string) {
|
||||
return date
|
||||
|
@ -38,13 +38,13 @@ enum Formatters {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
static func encodeISO8601(date: Date, encoder: Encoder) throws {
|
||||
var container = encoder.singleValueContainer()
|
||||
let dateString = iso8601WithoutFractionalSeconds.string(from: date)
|
||||
try container.encode(dateString)
|
||||
}
|
||||
|
||||
|
||||
static func decodeISO8601(decoder: Decoder) throws -> Date {
|
||||
let container = try decoder.singleValueContainer()
|
||||
let dateString = try container.decode(String.self)
|
||||
|
|
|
@ -17,29 +17,29 @@ public struct Page {
|
|||
public var previousPage: Int?
|
||||
public var firstPage: Int?
|
||||
public var lastPage: Int?
|
||||
|
||||
|
||||
init?(for header: String) {
|
||||
guard !header.isEmpty else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
for link in header.split(separator: ",") {
|
||||
let segments = link
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
.split(separator: ";")
|
||||
guard
|
||||
segments.count <= 2,
|
||||
|
||||
|
||||
let urlString = segments.first,
|
||||
urlString.hasPrefix("<") && urlString.hasSuffix(">"),
|
||||
|
||||
|
||||
let url = URLComponents(string: String(urlString.dropFirst().dropLast())),
|
||||
|
||||
|
||||
let pageString = url.queryItems?.first(where: { $0.name == "page" })?.value,
|
||||
let page = Int(pageString) else {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
for segment in segments.dropFirst() {
|
||||
switch segment.trimmingCharacters(in: .whitespacesAndNewlines) {
|
||||
case "rel=\"next\"":
|
||||
|
@ -61,7 +61,7 @@ public struct Page {
|
|||
public struct PageOptions {
|
||||
public var page: Int
|
||||
public var perPage: Int
|
||||
|
||||
|
||||
public init(page: Int, perPage: Int) {
|
||||
self.page = page
|
||||
self.perPage = perPage
|
||||
|
@ -87,4 +87,3 @@ private extension Array where Element == URLQueryItem {
|
|||
append(URLQueryItem(name: "per_page", value: String(pageOptions.perPage)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,19 +43,19 @@ extension URLRequest {
|
|||
resource.transformRequest(&request)
|
||||
self = request
|
||||
}
|
||||
|
||||
|
||||
init<R: Resource & HasRequestBody>(_ resource: R, configuration: Configuration, encoder: JSONEncoder) throws {
|
||||
self.init(resource, configuration: configuration)
|
||||
httpBody = try encoder.encode(resource.body)
|
||||
}
|
||||
|
||||
|
||||
init<R: Resource & Paginated>(_ resource: R, configuration: Configuration, pageOptions: PageOptions? = nil) {
|
||||
self.init(resource, configuration: configuration)
|
||||
if let options = pageOptions {
|
||||
appendPageOptions(options)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
init<R: Resource & HasRequestBody & Paginated>(_ resource: R, configuration: Configuration, encoder: JSONEncoder, pageOptions: PageOptions? = nil) throws {
|
||||
try self.init(resource, configuration: configuration, encoder: encoder)
|
||||
if let options = pageOptions {
|
||||
|
|
|
@ -21,13 +21,13 @@ public struct BuildkiteError: Error {
|
|||
public var statusCode: StatusCode
|
||||
public var message: String
|
||||
public var errors: [String]
|
||||
|
||||
|
||||
init(statusCode: StatusCode, intermediary: Intermediary) {
|
||||
self.statusCode = statusCode
|
||||
self.message = intermediary.message ?? ""
|
||||
self.errors = intermediary.errors ?? []
|
||||
}
|
||||
|
||||
|
||||
struct Intermediary: Codable {
|
||||
var message: String?
|
||||
var errors: [String]?
|
||||
|
|
|
@ -24,7 +24,7 @@ public enum StatusCode: Int, Error, Codable {
|
|||
|
||||
/// The request was found
|
||||
case found = 302
|
||||
|
||||
|
||||
/// The response to the request can be found under a different URL in the Location header and can be retrieved using a GET method on that resource.
|
||||
case seeOther = 303
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ extension Array where Element == URLQueryItem {
|
|||
}
|
||||
append(URLQueryItem(name: key, value: String(value)))
|
||||
}
|
||||
|
||||
|
||||
enum ArrayFormat {
|
||||
case indices
|
||||
case brackets
|
||||
|
||||
|
||||
func format(for index: Int) -> String {
|
||||
switch self {
|
||||
case .indices:
|
||||
|
@ -33,7 +33,7 @@ extension Array where Element == URLQueryItem {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mutating func append(_ items: [String], forKey key: String, arrayFormat: ArrayFormat = .brackets) {
|
||||
if items.isEmpty {
|
||||
return
|
||||
|
@ -48,7 +48,7 @@ extension Array where Element == URLQueryItem {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mutating func append(_ items: [String: String], forKey key: String) {
|
||||
append(contentsOf: items.map {
|
||||
URLQueryItem(name: "\(key)[\($0.key)]",
|
||||
|
|
|
@ -23,7 +23,7 @@ extension AccessToken.Resources {
|
|||
public struct Get: Resource, HasResponseBody {
|
||||
public typealias Content = AccessToken
|
||||
public let path = "access-token"
|
||||
|
||||
|
||||
public init() {}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ extension AccessToken.Resources {
|
|||
public let path = "access-token"
|
||||
|
||||
public init() {}
|
||||
|
||||
|
||||
public func transformRequest(_ request: inout URLRequest) {
|
||||
request.httpMethod = "DELETE"
|
||||
}
|
||||
|
|
|
@ -31,15 +31,15 @@ extension Agent.Resources {
|
|||
public var hostname: String?
|
||||
/// Filters the results by the given exact version number
|
||||
public var version: String?
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/agents"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String) {
|
||||
self.organization = organization
|
||||
}
|
||||
|
||||
|
||||
public func transformRequest(_ request: inout URLRequest) {
|
||||
guard let url = request.url,
|
||||
var components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
|
||||
|
@ -64,7 +64,7 @@ extension Agent.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)/agents/\(agentId)"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, agentId: UUID) {
|
||||
self.organization = organization
|
||||
self.agentId = agentId
|
||||
|
@ -82,7 +82,7 @@ extension Agent.Resources {
|
|||
public var agentId: UUID
|
||||
/// body of the request
|
||||
public var body: Body
|
||||
|
||||
|
||||
public struct Body: Codable {
|
||||
/// If the agent is currently processing a job, the job and the build will be canceled.
|
||||
public var force: Bool?
|
||||
|
@ -91,7 +91,7 @@ extension Agent.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)/agents/\(agentId)/stop"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, agentId: UUID, body: Agent.Resources.Stop.Body) {
|
||||
self.organization = organization
|
||||
self.agentId = agentId
|
||||
|
|
|
@ -28,11 +28,11 @@ extension Annotation.Resources {
|
|||
public var pipeline: String
|
||||
/// build number
|
||||
public var build: Int
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/annotations"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
|
|
@ -28,11 +28,11 @@ extension Artifact.Resources {
|
|||
public var pipeline: String
|
||||
/// build number
|
||||
public var build: Int
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/artifacts"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -53,11 +53,11 @@ extension Artifact.Resources {
|
|||
public var build: Int
|
||||
/// job ID
|
||||
public var jobId: UUID
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/jobs/\(jobId)/artifacts"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int, jobId: UUID) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -83,7 +83,7 @@ extension Artifact.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/jobs/\(jobId)/artifacts/\(artifactId)"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int, jobId: UUID, artifactId: UUID) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -112,7 +112,7 @@ extension Artifact.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/jobs/\(jobId)/artifacts/\(artifactId)/download"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int, jobId: UUID, artifactId: UUID) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -141,7 +141,7 @@ extension Artifact.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/jobs/\(jobId)/artifacts/\(artifactId)"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int, jobId: UUID, artifactId: UUID) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
|
|
@ -24,13 +24,13 @@ extension Build.Resources {
|
|||
public struct ListAll: Resource, HasResponseBody, Paginated {
|
||||
public typealias Content = [Build]
|
||||
public let path = "builds"
|
||||
|
||||
|
||||
public var queryOptions: QueryOptions?
|
||||
|
||||
|
||||
public init(queryOptions: Build.Resources.QueryOptions? = nil) {
|
||||
self.queryOptions = queryOptions
|
||||
}
|
||||
|
||||
|
||||
public func transformRequest(_ request: inout URLRequest) {
|
||||
guard let url = request.url,
|
||||
var components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
|
||||
|
@ -53,13 +53,13 @@ extension Build.Resources {
|
|||
public typealias Content = [Build]
|
||||
/// organization slug
|
||||
public var organization: String
|
||||
|
||||
|
||||
public var queryOptions: QueryOptions?
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/builds"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, queryOptions: Build.Resources.QueryOptions? = nil) {
|
||||
self.organization = organization
|
||||
self.queryOptions = queryOptions
|
||||
|
@ -88,19 +88,19 @@ extension Build.Resources {
|
|||
public var organization: String
|
||||
/// pipeline slug
|
||||
public var pipeline: String
|
||||
|
||||
|
||||
public var queryOptions: QueryOptions?
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, queryOptions: Build.Resources.QueryOptions? = nil) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
self.queryOptions = queryOptions
|
||||
}
|
||||
|
||||
|
||||
public func transformRequest(_ request: inout URLRequest) {
|
||||
guard let url = request.url,
|
||||
var components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
|
||||
|
@ -128,7 +128,7 @@ extension Build.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -150,7 +150,7 @@ extension Build.Resources {
|
|||
public struct Author: Codable {
|
||||
public var name: String
|
||||
public var email: String
|
||||
|
||||
|
||||
public init(name: String, email: String) {
|
||||
self.name = name
|
||||
self.email = email
|
||||
|
@ -180,8 +180,8 @@ extension Build.Resources {
|
|||
public var pullRequestId: Int?
|
||||
/// For a pull request build, the git repository of the pull request.
|
||||
public var pullRequestRepository: String?
|
||||
|
||||
public init(commit: String, branch: String, author: Build.Resources.Create.Body.Author? = nil, cleanCheckout: Bool? = nil, env: [String : String]? = nil, ignorePipelineBranchFilters: Bool? = nil, message: String? = nil, metaData: [String : String]? = nil, pullRequestBaseBranch: String? = nil, pullRequestId: Int? = nil, pullRequestRepository: String? = nil) {
|
||||
|
||||
public init(commit: String, branch: String, author: Build.Resources.Create.Body.Author? = nil, cleanCheckout: Bool? = nil, env: [String: String]? = nil, ignorePipelineBranchFilters: Bool? = nil, message: String? = nil, metaData: [String: String]? = nil, pullRequestBaseBranch: String? = nil, pullRequestId: Int? = nil, pullRequestRepository: String? = nil) {
|
||||
self.commit = commit
|
||||
self.branch = branch
|
||||
self.author = author
|
||||
|
@ -200,7 +200,7 @@ extension Build.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, body: Body) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -227,13 +227,13 @@ extension Build.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/cancel"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
self.build = build
|
||||
}
|
||||
|
||||
|
||||
public func transformRequest(_ request: inout URLRequest) {
|
||||
request.httpMethod = "PUT"
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ extension Build.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/rebuild"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -265,7 +265,7 @@ extension Build.Resources {
|
|||
request.httpMethod = "PUT"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public struct QueryOptions {
|
||||
/// Filters the results by the given branch or branches.
|
||||
public var branches: [String] = []
|
||||
|
@ -285,8 +285,8 @@ extension Build.Resources {
|
|||
public var metadata: [String: String] = [:]
|
||||
/// Filters the results by the given build state. The finished state is a shortcut to automatically search for builds with passed, failed, blocked, canceled states.
|
||||
public var state: [Build.State]
|
||||
|
||||
public init(branches: [String] = [], commit: String? = nil, createdFrom: Date? = nil, createdTo: Date? = nil, creator: UUID? = nil, finishedFrom: Date? = nil, includeRetriedJobs: Bool? = nil, metadata: [String : String] = [:], state: [Build.State] = []) {
|
||||
|
||||
public init(branches: [String] = [], commit: String? = nil, createdFrom: Date? = nil, createdTo: Date? = nil, creator: UUID? = nil, finishedFrom: Date? = nil, includeRetriedJobs: Bool? = nil, metadata: [String: String] = [:], state: [Build.State] = []) {
|
||||
self.branches = branches
|
||||
self.commit = commit
|
||||
self.createdFrom = createdFrom
|
||||
|
@ -300,7 +300,6 @@ extension Build.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private extension Array where Element == URLQueryItem {
|
||||
init(queryOptions: Build.Resources.QueryOptions) {
|
||||
self.init()
|
||||
|
|
|
@ -28,7 +28,7 @@ extension Emoji.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)/emojis"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String) {
|
||||
self.organization = organization
|
||||
}
|
||||
|
|
|
@ -30,15 +30,15 @@ extension Job.Resources {
|
|||
public var build: Int
|
||||
/// job ID
|
||||
public var job: UUID
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/jobs/\(job)/retry"
|
||||
}
|
||||
|
||||
|
||||
public func transformRequest(_ request: inout URLRequest) {
|
||||
request.httpMethod = "PUT"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int, job: UUID) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -46,7 +46,7 @@ extension Job.Resources {
|
|||
self.job = job
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Unblock a job
|
||||
///
|
||||
/// Unblocks a build’s "Block pipeline" job. The job’s `unblockable` property indicates whether it is able to be unblocked, and the `unblock_url` property points to this endpoint.
|
||||
|
@ -62,21 +62,21 @@ extension Job.Resources {
|
|||
public var job: UUID
|
||||
/// body of the request
|
||||
public var body: Body
|
||||
|
||||
|
||||
public struct Body: Codable {
|
||||
public var unblocker: UUID?
|
||||
public var fields: [String: String]
|
||||
|
||||
public init(unblocker: UUID? = nil, fields: [String : String] = [:]) {
|
||||
|
||||
public init(unblocker: UUID? = nil, fields: [String: String] = [:]) {
|
||||
self.unblocker = unblocker
|
||||
self.fields = fields
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/jobs/\(job)/unblock"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int, job: UUID, body: Job.Resources.Unblock.Body) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -84,12 +84,12 @@ extension Job.Resources {
|
|||
self.job = job
|
||||
self.body = body
|
||||
}
|
||||
|
||||
|
||||
public func transformRequest(_ request: inout URLRequest) {
|
||||
request.httpMethod = "PUT"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Get a job’s log output
|
||||
public struct LogOutput: Resource, HasResponseBody {
|
||||
public typealias Content = Job.LogOutput
|
||||
|
@ -101,11 +101,11 @@ extension Job.Resources {
|
|||
public var build: Int
|
||||
/// job ID
|
||||
public var job: UUID
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/jobs/\(job)/log"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int, job: UUID) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -113,7 +113,7 @@ extension Job.Resources {
|
|||
self.job = job
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Delete a job’s log output
|
||||
public struct DeleteLogOutput: Resource {
|
||||
public typealias Content = Void
|
||||
|
@ -125,23 +125,23 @@ extension Job.Resources {
|
|||
public var build: Int
|
||||
/// job ID
|
||||
public var job: UUID
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/jobs/\(job)/log"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int, job: UUID) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
self.build = build
|
||||
self.job = job
|
||||
}
|
||||
|
||||
|
||||
public func transformRequest(_ request: inout URLRequest) {
|
||||
request.httpMethod = "DELETE"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Get a job's environment variables
|
||||
public struct EnvironmentVariables: Resource, HasResponseBody {
|
||||
public typealias Content = Job.EnvironmentVariables
|
||||
|
@ -153,11 +153,11 @@ extension Job.Resources {
|
|||
public var build: Int
|
||||
/// job ID
|
||||
public var job: UUID
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/jobs/\(job)/env"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int, job: UUID) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
@ -176,7 +176,7 @@ extension Job.Resources.LogOutput {
|
|||
case html
|
||||
case plainText = "txt"
|
||||
}
|
||||
|
||||
|
||||
public typealias Content = String
|
||||
/// organization slug
|
||||
public var organization: String
|
||||
|
@ -186,13 +186,13 @@ extension Job.Resources.LogOutput {
|
|||
public var build: Int
|
||||
/// job ID
|
||||
public var job: UUID
|
||||
|
||||
|
||||
public var format: Format
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)/builds/\(build)/jobs/\(job)/log.\(format)"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, build: Int, job: UUID, format: Format) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
|
|
@ -23,7 +23,7 @@ extension Organization.Resources {
|
|||
public struct List: Resource, HasResponseBody, Paginated {
|
||||
public typealias Content = [Organization]
|
||||
public let path = "organizations"
|
||||
|
||||
|
||||
public init() {
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ extension Organization.Resources {
|
|||
public var path: String {
|
||||
"organizations/\(organization)"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String) {
|
||||
self.organization = organization
|
||||
}
|
||||
|
|
|
@ -24,16 +24,16 @@ extension Pipeline.Resources {
|
|||
public typealias Content = [Pipeline]
|
||||
/// organization slug
|
||||
public var organization: String
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String) {
|
||||
self.organization = organization
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Get a pipeline
|
||||
public struct Get: Resource, HasResponseBody {
|
||||
public typealias Content = Pipeline
|
||||
|
@ -41,25 +41,25 @@ extension Pipeline.Resources {
|
|||
public var organization: String
|
||||
/// pipeline slug
|
||||
public var pipeline: String
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Create a pipeline
|
||||
public struct Create: Resource, HasRequestBody, HasResponseBody {
|
||||
public typealias Content = Pipeline
|
||||
/// organization slug
|
||||
public var organization: String
|
||||
|
||||
|
||||
public var body: Body
|
||||
|
||||
|
||||
public struct Body: Codable {
|
||||
/// The name of the pipeline.
|
||||
public var name: String
|
||||
|
@ -67,7 +67,7 @@ extension Pipeline.Resources {
|
|||
public var repository: URL
|
||||
/// An array of the build pipeline steps.
|
||||
public var steps: [Pipeline.Step]
|
||||
|
||||
|
||||
/// A branch filter pattern to limit which pushed branches trigger builds on this pipeline.
|
||||
public var branchConfiguration: String?
|
||||
/// Cancel intermediate builds. When a new build is created on a branch, any previous builds that are running on the same branch will be automatically canceled.
|
||||
|
@ -88,8 +88,8 @@ extension Pipeline.Resources {
|
|||
public var skipQueuedBranchBuildsFilter: String?
|
||||
/// An array of team UUIDs to add this pipeline to. You can find your team’s UUID either via the GraphQL API, or on the settings page for a team. This property is only available if your organization has enabled Teams.
|
||||
public var teamUUIDs: [UUID]?
|
||||
|
||||
public init(name: String, repository: URL, steps: [Pipeline.Step], branchConfiguration: String? = nil, cancelRunningBranchBuilds: Bool? = nil, cancelRunningBranchBuildsFilter: String? = nil, defaultBranch: String? = nil, description: String? = nil, env: [String : String]? = nil, providerSettings: Pipeline.Provider.Settings? = nil, skipQueuedBranchBuilds: Bool? = nil, skipQueuedBranchBuildsFilter: String? = nil, teamUUIDs: [UUID]? = nil) {
|
||||
|
||||
public init(name: String, repository: URL, steps: [Pipeline.Step], branchConfiguration: String? = nil, cancelRunningBranchBuilds: Bool? = nil, cancelRunningBranchBuildsFilter: String? = nil, defaultBranch: String? = nil, description: String? = nil, env: [String: String]? = nil, providerSettings: Pipeline.Provider.Settings? = nil, skipQueuedBranchBuilds: Bool? = nil, skipQueuedBranchBuildsFilter: String? = nil, teamUUIDs: [UUID]? = nil) {
|
||||
self.name = name
|
||||
self.repository = repository
|
||||
self.steps = steps
|
||||
|
@ -105,21 +105,21 @@ extension Pipeline.Resources {
|
|||
self.teamUUIDs = teamUUIDs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, body: Pipeline.Resources.Create.Body) {
|
||||
self.organization = organization
|
||||
self.body = body
|
||||
}
|
||||
|
||||
|
||||
public func transformRequest(_ request: inout URLRequest) {
|
||||
request.httpMethod = "POST"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Update a pipeline
|
||||
///
|
||||
/// Updates one or more properties of an existing pipeline
|
||||
|
@ -129,9 +129,9 @@ extension Pipeline.Resources {
|
|||
public var organization: String
|
||||
/// pipeline slug
|
||||
public var pipeline: String
|
||||
|
||||
|
||||
public var body: Body
|
||||
|
||||
|
||||
public struct Body: Codable {
|
||||
/// A branch filter pattern to limit which pushed branches trigger builds on this pipeline.
|
||||
public var branchConfiguration: String?
|
||||
|
@ -159,8 +159,8 @@ extension Pipeline.Resources {
|
|||
public var skipQueuedBranchBuildsFilter: String?
|
||||
/// Whether the pipeline is visible to everyone, including users outside this organization.
|
||||
public var visibility: String?
|
||||
|
||||
public init(branchConfiguration: String? = nil, cancelRunningBranchBuilds: Bool? = nil, cancelRunningBranchBuildsFilter: String? = nil, defaultBranch: String? = nil, description: String? = nil, env: [String : String]? = nil, name: String? = nil, providerSettings: Pipeline.Provider.Settings? = nil, repository: URL? = nil, steps: [Pipeline.Step]? = nil, skipQueuedBranchBuilds: Bool? = nil, skipQueuedBranchBuildsFilter: String? = nil, visibility: String? = nil) {
|
||||
|
||||
public init(branchConfiguration: String? = nil, cancelRunningBranchBuilds: Bool? = nil, cancelRunningBranchBuildsFilter: String? = nil, defaultBranch: String? = nil, description: String? = nil, env: [String: String]? = nil, name: String? = nil, providerSettings: Pipeline.Provider.Settings? = nil, repository: URL? = nil, steps: [Pipeline.Step]? = nil, skipQueuedBranchBuilds: Bool? = nil, skipQueuedBranchBuildsFilter: String? = nil, visibility: String? = nil) {
|
||||
self.branchConfiguration = branchConfiguration
|
||||
self.cancelRunningBranchBuilds = cancelRunningBranchBuilds
|
||||
self.cancelRunningBranchBuildsFilter = cancelRunningBranchBuildsFilter
|
||||
|
@ -176,18 +176,18 @@ extension Pipeline.Resources {
|
|||
self.visibility = visibility
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String, body: Pipeline.Resources.Update.Body) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
self.body = body
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Delete a pipeline
|
||||
public struct Delete: Resource {
|
||||
public typealias Content = Void
|
||||
|
@ -195,11 +195,11 @@ extension Pipeline.Resources {
|
|||
public var organization: String
|
||||
/// pipeline slug
|
||||
public var pipeline: String
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/pipelines/\(pipeline)"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, pipeline: String) {
|
||||
self.organization = organization
|
||||
self.pipeline = pipeline
|
||||
|
|
|
@ -23,16 +23,16 @@ extension Team.Resources {
|
|||
public var organization: String
|
||||
/// Filters the results to teams that have the given user as a member.
|
||||
public var userId: UUID?
|
||||
|
||||
|
||||
public var path: String {
|
||||
"organizations/\(organization)/teams"
|
||||
}
|
||||
|
||||
|
||||
public init(organization: String, userId: UUID? = nil) {
|
||||
self.organization = organization
|
||||
self.userId = userId
|
||||
}
|
||||
|
||||
|
||||
public func transformRequest(_ request: inout URLRequest) {
|
||||
guard let url = request.url,
|
||||
var components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
|
||||
|
|
|
@ -20,7 +20,7 @@ extension User.Resources {
|
|||
public struct Me: Resource, HasResponseBody {
|
||||
public typealias Content = User
|
||||
public let path = "user"
|
||||
|
||||
|
||||
public init() {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,14 +30,14 @@ class BuildkiteTests: XCTestCase {
|
|||
case unsuccessfulResponse
|
||||
case noData
|
||||
}
|
||||
|
||||
|
||||
var configuration = Configuration.default
|
||||
var client: Buildkite
|
||||
var resources = MockResources()
|
||||
|
||||
|
||||
init(testCase: Case = .success) throws {
|
||||
let responses: [(Data, URLResponse)]
|
||||
|
||||
|
||||
switch testCase {
|
||||
case .success:
|
||||
responses = [try MockData.mockingSuccess(with: resources.content, url: configuration.baseURL)]
|
||||
|
@ -56,7 +56,7 @@ class BuildkiteTests: XCTestCase {
|
|||
case .noData:
|
||||
responses = []
|
||||
}
|
||||
|
||||
|
||||
client = Buildkite(configuration: configuration,
|
||||
transport: MockTransport(responses: responses))
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class BuildkiteTests: XCTestCase {
|
|||
extension BuildkiteTests {
|
||||
func testClosureBasedRequest() throws {
|
||||
let testData = try TestData(testCase: .success)
|
||||
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
testData.client.send(testData.resources.contentResource) { result in
|
||||
do {
|
||||
|
@ -81,10 +81,10 @@ extension BuildkiteTests {
|
|||
}
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testClosureBasedRequestWithPagination() throws {
|
||||
let testData = try TestData(testCase: .success)
|
||||
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
testData.client.send(testData.resources.paginatedContentResource, pageOptions: PageOptions(page: 1, perPage: 30)) { result in
|
||||
do {
|
||||
|
@ -98,30 +98,30 @@ extension BuildkiteTests {
|
|||
}
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testClosureBasedRequestNoContent() throws {
|
||||
let testData = try TestData(testCase: .successNoContent)
|
||||
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
testData.client.send(testData.resources.noContentNoBodyResource) { _ in
|
||||
expectation.fulfill()
|
||||
}
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testClosureBasedRequestHasBody() throws {
|
||||
let testData = try TestData(testCase: .successHasBody)
|
||||
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
testData.client.send(testData.resources.bodyResource) { _ in
|
||||
expectation.fulfill()
|
||||
}
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testClosureBasedRequestHasBodyWithPagination() throws {
|
||||
let testData = try TestData(testCase: .successHasBodyPaginated)
|
||||
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
testData.client.send(testData.resources.bodyAndPaginatedResource, pageOptions: PageOptions(page: 1, perPage: 30)) { result in
|
||||
do {
|
||||
|
@ -135,7 +135,7 @@ extension BuildkiteTests {
|
|||
}
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testClosureBasedRequestInvalidResponse() throws {
|
||||
let testData = try TestData(testCase: .badResponse)
|
||||
let expectation = XCTestExpectation()
|
||||
|
@ -149,7 +149,7 @@ extension BuildkiteTests {
|
|||
}
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testClosureBasedRequestUnsuccessfulResponse() throws {
|
||||
let testData = try TestData(testCase: .unsuccessfulResponse)
|
||||
let expectation = XCTestExpectation()
|
||||
|
@ -164,7 +164,7 @@ extension BuildkiteTests {
|
|||
}
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testFailureFromTransport() throws {
|
||||
let testData = try TestData(testCase: .noData)
|
||||
let expectation = XCTestExpectation()
|
||||
|
@ -201,7 +201,7 @@ extension BuildkiteTests {
|
|||
.store(in: &cancellables)
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testPublisherBasedRequestWithPagination() throws {
|
||||
let testData = try TestData(testCase: .success)
|
||||
let expectation = XCTestExpectation()
|
||||
|
@ -220,7 +220,7 @@ extension BuildkiteTests {
|
|||
.store(in: &cancellables)
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testPublisherBasedRequestNoContent() throws {
|
||||
let testData = try TestData(testCase: .success)
|
||||
let expectation = XCTestExpectation()
|
||||
|
@ -235,7 +235,7 @@ extension BuildkiteTests {
|
|||
.store(in: &cancellables)
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testPublisherBasedRequestHasBody() throws {
|
||||
let testData = try TestData(testCase: .successHasBody)
|
||||
let expectation = XCTestExpectation()
|
||||
|
@ -250,7 +250,7 @@ extension BuildkiteTests {
|
|||
.store(in: &cancellables)
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testPublisherBasedRequestHasBodyWithPagination() throws {
|
||||
let testData = try TestData(testCase: .successHasBodyPaginated)
|
||||
let expectation = XCTestExpectation()
|
||||
|
@ -269,7 +269,7 @@ extension BuildkiteTests {
|
|||
.store(in: &cancellables)
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testPublisherBasedRequestInvalidResponse() throws {
|
||||
let testData = try TestData(testCase: .badResponse)
|
||||
let expectation = XCTestExpectation()
|
||||
|
@ -284,7 +284,7 @@ extension BuildkiteTests {
|
|||
.store(in: &cancellables)
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testPublisherBasedRequestUnsuccessfulResponse() throws {
|
||||
let testData = try TestData(testCase: .unsuccessfulResponse)
|
||||
let expectation = XCTestExpectation()
|
||||
|
|
|
@ -99,7 +99,7 @@ class AgentsTests: XCTestCase {
|
|||
let resource = Agent.Resources.Stop(organization: "buildkite",
|
||||
agentId: UUID(),
|
||||
body: Agent.Resources.Stop.Body(force: true))
|
||||
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
context.client.send(resource) { result in
|
||||
do {
|
||||
|
|
|
@ -91,7 +91,7 @@ class BuildsTests: XCTestCase {
|
|||
let context = try MockContext(content: expected)
|
||||
|
||||
let resource = Build.Resources.ListForOrganization(organization: "buildkite", queryOptions: Build.Resources.QueryOptions())
|
||||
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
|
||||
context.client.send(resource) { result in
|
||||
|
|
|
@ -71,7 +71,7 @@ class JobsTests: XCTestCase {
|
|||
}
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
#if !os(Linux)
|
||||
func testJobsLogOutputAlternativePlainText() throws {
|
||||
let expected = "hello friends"
|
||||
|
@ -90,7 +90,7 @@ class JobsTests: XCTestCase {
|
|||
}
|
||||
wait(for: [expectation])
|
||||
}
|
||||
|
||||
|
||||
func testJobsLogOutputAlternativeHTML() throws {
|
||||
let expected = "hello friends"
|
||||
let context = try MockContext(content: expected)
|
||||
|
|
|
@ -208,7 +208,7 @@ extension PipelinesTests {
|
|||
.number(1),
|
||||
.number(2),
|
||||
.number(3),
|
||||
.number(4),
|
||||
.number(4)
|
||||
]),
|
||||
"bigs": .dictionary([
|
||||
"vending": .string("machine"),
|
||||
|
@ -216,7 +216,7 @@ extension PipelinesTests {
|
|||
])
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
func testEnvVarDecodeEncode() throws {
|
||||
let testData = EnvVarTestData()
|
||||
let data = try JSONEncoder().encode(testData.object)
|
||||
|
|
|
@ -20,7 +20,7 @@ struct MockResources {
|
|||
}
|
||||
|
||||
var noContentNoBodyResource = NoContentNoBody()
|
||||
|
||||
|
||||
struct HasContent: Resource, HasResponseBody {
|
||||
struct Content: Codable, Equatable {
|
||||
var name: String
|
||||
|
@ -28,51 +28,51 @@ struct MockResources {
|
|||
}
|
||||
let path = "mock"
|
||||
}
|
||||
|
||||
|
||||
var contentResource = HasContent()
|
||||
var content = HasContent.Content(name: "Jeff", age: 35)
|
||||
|
||||
|
||||
struct HasPaginatedContent: Resource, Paginated {
|
||||
struct Content: Codable, Equatable {
|
||||
var name: String
|
||||
var age: Int
|
||||
}
|
||||
|
||||
|
||||
let path = "mock"
|
||||
}
|
||||
|
||||
|
||||
var paginatedContentResource = HasPaginatedContent()
|
||||
var paginatedContent = HasPaginatedContent.Content(name: "Jeff", age: 35)
|
||||
|
||||
|
||||
struct HasBody: Resource, HasRequestBody {
|
||||
struct Body: Codable, Equatable {
|
||||
var name: String
|
||||
var age: Int
|
||||
}
|
||||
|
||||
|
||||
var body: Body
|
||||
|
||||
|
||||
let path = "mock"
|
||||
}
|
||||
|
||||
|
||||
var bodyResource = HasBody(body: HasBody.Body(name: "Jeff", age: 35))
|
||||
|
||||
|
||||
struct HasBodyAndPaginated: Resource, HasRequestBody, Paginated {
|
||||
struct Body: Codable, Equatable {
|
||||
var name: String
|
||||
var age: Int
|
||||
}
|
||||
|
||||
|
||||
struct Content: Codable, Equatable {
|
||||
var name: String
|
||||
var age: Int
|
||||
}
|
||||
|
||||
|
||||
var body: Body
|
||||
|
||||
|
||||
let path = "mock"
|
||||
}
|
||||
|
||||
|
||||
var bodyAndPaginatedResource = HasBodyAndPaginated(body: HasBodyAndPaginated.Body(name: "Jeff", age: 35))
|
||||
var bodyAndPaginatedContent = HasBodyAndPaginated.Content(name: "Jeff", age: 35)
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ extension MockData {
|
|||
HTTPURLResponse(url: url,
|
||||
statusCode: status,
|
||||
httpVersion: "HTTP/1.1",
|
||||
headerFields: ["Link":#"<https://api.buildkite.com/v2/organizations/my-great-org/pipelines/my-pipeline/builds?api_key=f8582f070276d764ce3dd4c6d57be92574dccf86&page=3>; rel="prev",<https://api.buildkite.com/v2/organizations/my-great-org/pipelines/my-pipeline/builds?api_key=f8582f070276d764ce3dd4c6d57be92574dccf86&page=5>; rel="next",<https://api.buildkite.com/v2/organizations/my-great-org/pipelines/my-pipeline/builds?api_key=f8582f070276d764ce3dd4c6d57be92574dccf86&page=1>; rel="first", <https://api.buildkite.com/v2/organizations/my-great-org/pipelines/my-pipeline/builds?api_key=f8582f070276d764ce3dd4c6d57be92574dccf86&page=10>; rel="last""#])!
|
||||
headerFields: ["Link": #"<https://api.buildkite.com/v2/organizations/my-great-org/pipelines/my-pipeline/builds?api_key=f8582f070276d764ce3dd4c6d57be92574dccf86&page=3>; rel="prev",<https://api.buildkite.com/v2/organizations/my-great-org/pipelines/my-pipeline/builds?api_key=f8582f070276d764ce3dd4c6d57be92574dccf86&page=5>; rel="next",<https://api.buildkite.com/v2/organizations/my-great-org/pipelines/my-pipeline/builds?api_key=f8582f070276d764ce3dd4c6d57be92574dccf86&page=1>; rel="first", <https://api.buildkite.com/v2/organizations/my-great-org/pipelines/my-pipeline/builds?api_key=f8582f070276d764ce3dd4c6d57be92574dccf86&page=10>; rel="last""#])!
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ extension AccessTokensTests {
|
|||
// to regenerate.
|
||||
static let __allTests__AccessTokensTests = [
|
||||
("testAccessTokenDelete", testAccessTokenDelete),
|
||||
("testAccessTokenGet", testAccessTokenGet),
|
||||
("testAccessTokenGet", testAccessTokenGet)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ extension AgentsTests {
|
|||
static let __allTests__AgentsTests = [
|
||||
("testAgentsGet", testAgentsGet),
|
||||
("testAgentsList", testAgentsList),
|
||||
("testAgentsStop", testAgentsStop),
|
||||
("testAgentsStop", testAgentsStop)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ extension AnnotationsTests {
|
|||
// `swift test --generate-linuxmain`
|
||||
// to regenerate.
|
||||
static let __allTests__AnnotationsTests = [
|
||||
("testAnnotationsList", testAnnotationsList),
|
||||
("testAnnotationsList", testAnnotationsList)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ extension ArtifactsTests {
|
|||
("testArtifactsDownload", testArtifactsDownload),
|
||||
("testArtifactsGet", testArtifactsGet),
|
||||
("testArtifactsListByBuild", testArtifactsListByBuild),
|
||||
("testArtifactsListByJob", testArtifactsListByJob),
|
||||
("testArtifactsListByJob", testArtifactsListByJob)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ extension BuildkiteTests {
|
|||
("testClosureBasedRequestNoContent", testClosureBasedRequestNoContent),
|
||||
("testClosureBasedRequestUnsuccessfulResponse", testClosureBasedRequestUnsuccessfulResponse),
|
||||
("testClosureBasedRequestWithPagination", testClosureBasedRequestWithPagination),
|
||||
("testFailureFromTransport", testFailureFromTransport),
|
||||
("testFailureFromTransport", testFailureFromTransport)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ extension BuildsTests {
|
|||
("testBuildsListAllSpecializedQuery", testBuildsListAllSpecializedQuery),
|
||||
("testBuildsListForOrganization", testBuildsListForOrganization),
|
||||
("testBuildsListForPipeline", testBuildsListForPipeline),
|
||||
("testBuildsRebuild", testBuildsRebuild),
|
||||
("testBuildsRebuild", testBuildsRebuild)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ extension EmojisTests {
|
|||
// `swift test --generate-linuxmain`
|
||||
// to regenerate.
|
||||
static let __allTests__EmojisTests = [
|
||||
("testEmojisList", testEmojisList),
|
||||
("testEmojisList", testEmojisList)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ extension JobsTests {
|
|||
("testJobsEnvironmentVariables", testJobsEnvironmentVariables),
|
||||
("testJobsLogOutput", testJobsLogOutput),
|
||||
("testJobsRetry", testJobsRetry),
|
||||
("testJobsUnblock", testJobsUnblock),
|
||||
("testJobsUnblock", testJobsUnblock)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ extension OrganizationsTests {
|
|||
// to regenerate.
|
||||
static let __allTests__OrganizationsTests = [
|
||||
("testOrganizationsGet", testOrganizationsGet),
|
||||
("testOrganizationsList", testOrganizationsList),
|
||||
("testOrganizationsList", testOrganizationsList)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ extension PipelinesTests {
|
|||
("testPipelinesDelete", testPipelinesDelete),
|
||||
("testPipelinesGet", testPipelinesGet),
|
||||
("testPipelinesList", testPipelinesList),
|
||||
("testPipelinesUpdate", testPipelinesUpdate),
|
||||
("testPipelinesUpdate", testPipelinesUpdate)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ extension StatusCodeTests {
|
|||
// `swift test --generate-linuxmain`
|
||||
// to regenerate.
|
||||
static let __allTests__StatusCodeTests = [
|
||||
("testFlag", testFlag),
|
||||
("testFlag", testFlag)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ extension TeamsTests {
|
|||
// `swift test --generate-linuxmain`
|
||||
// to regenerate.
|
||||
static let __allTests__TeamsTests = [
|
||||
("testTeamsList", testTeamsList),
|
||||
("testTeamsList", testTeamsList)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ extension TransportTests {
|
|||
// to regenerate.
|
||||
static let __allTests__TransportTests = [
|
||||
("testURLSessionSendClosureBasedRequest", testURLSessionSendClosureBasedRequest),
|
||||
("testURLSessionSendClosureBasedRequestFailure", testURLSessionSendClosureBasedRequestFailure),
|
||||
("testURLSessionSendClosureBasedRequestFailure", testURLSessionSendClosureBasedRequestFailure)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ extension UsersTests {
|
|||
// `swift test --generate-linuxmain`
|
||||
// to regenerate.
|
||||
static let __allTests__UsersTests = [
|
||||
("testUserMe", testUserMe),
|
||||
("testUserMe", testUserMe)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ public func __allTests() -> [XCTestCaseEntry] {
|
|||
testCase(StatusCodeTests.__allTests__StatusCodeTests),
|
||||
testCase(TeamsTests.__allTests__TeamsTests),
|
||||
testCase(TransportTests.__allTests__TransportTests),
|
||||
testCase(UsersTests.__allTests__UsersTests),
|
||||
testCase(UsersTests.__allTests__UsersTests)
|
||||
]
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue