mirror of
https://github.com/gosticks/SwiftGit2.git
synced 2025-10-16 11:55:34 +00:00
updated to Xcode 7.2 recommended settings integrated with Nimble (v3.0.0), Quick (v0.8.0), Result (1.0.1) integrated with Guanaco (5031bf67297afbe61ac0f2fbf3e3e8400b3f8888) that supports Swift 2.0
78 lines
1.9 KiB
Swift
78 lines
1.9 KiB
Swift
//
|
|
// Fixtures.swift
|
|
// SwiftGit2
|
|
//
|
|
// Created by Matt Diephouse on 11/16/14.
|
|
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftGit2
|
|
|
|
final class Fixtures {
|
|
|
|
// MARK: Lifecycle
|
|
|
|
class var sharedInstance: Fixtures {
|
|
struct Singleton {
|
|
static let instance = Fixtures()
|
|
}
|
|
return Singleton.instance
|
|
}
|
|
|
|
init() {
|
|
directoryURL = NSURL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
|
.URLByAppendingPathComponent("org.libgit2.SwiftGit2")
|
|
.URLByAppendingPathComponent(NSProcessInfo.processInfo().globallyUniqueString)
|
|
}
|
|
|
|
// MARK: - Setup and Teardown
|
|
|
|
let directoryURL: NSURL
|
|
|
|
func setUp() {
|
|
try! NSFileManager.defaultManager().createDirectoryAtURL(directoryURL, withIntermediateDirectories: true, attributes: nil)
|
|
|
|
let bundle = NSBundle(identifier: "org.libgit2.SwiftGit2-OSXTests")!
|
|
let zipURLs = bundle.URLsForResourcesWithExtension("zip", subdirectory: nil)! as [NSURL]
|
|
|
|
for URL in zipURLs {
|
|
unzipFileAtURL(URL, intoDirectoryAtURL: directoryURL)
|
|
}
|
|
}
|
|
|
|
func tearDown() {
|
|
try! NSFileManager.defaultManager().removeItemAtURL(directoryURL)
|
|
}
|
|
|
|
func unzipFileAtURL(fileURL: NSURL, intoDirectoryAtURL directoryURL: NSURL) {
|
|
let task = NSTask()
|
|
task.launchPath = "/usr/bin/unzip"
|
|
task.arguments = [ "-qq", "-d", directoryURL.path!, fileURL.path! ]
|
|
|
|
task.launch()
|
|
task.waitUntilExit()
|
|
}
|
|
|
|
// MARK: - Helpers
|
|
|
|
func repositoryWithName(name: String) -> Repository {
|
|
let url = directoryURL.URLByAppendingPathComponent(name, isDirectory: true)
|
|
return Repository.atURL(url).value!
|
|
}
|
|
|
|
// MARK: - The Fixtures
|
|
|
|
class var detachedHeadRepository: Repository {
|
|
return Fixtures.sharedInstance.repositoryWithName("detached-head")
|
|
}
|
|
|
|
class var simpleRepository: Repository {
|
|
return Fixtures.sharedInstance.repositoryWithName("simple-repository")
|
|
}
|
|
|
|
class var mantleRepository: Repository {
|
|
return Fixtures.sharedInstance.repositoryWithName("Mantle")
|
|
}
|
|
}
|