// // P4LIbraryTests.swift // DocHub // // Created by Tristan Juricek on 6/11/14. // Copyright (c) 2014 Perforce. All rights reserved. // import XCTest import DocHub class P4LibraryTests: XCTestCase { let settings = P4ConnectionSettings( hostname: "localhost", port: 1666, login: "jdoe", token: "johndoe1A", charset: nil ) func testListDepots() { let p4Library = P4Library(settings: settings) XCTAssert(p4Library.depots.count == 2, "Should be two depots") XCTAssert(p4Library.depots.filter({$0.name == "depot"}).count > 0, "Did not find the 'depot' depot") XCTAssert(p4Library.depots.filter({$0.name == "documents"}).count > 0, "Did not find the 'documents' depot") } func testListDirsForDepot() { let p4Library = P4Library(settings: settings) let depot = p4Library.depots.filter({$0.name == "depot"})[0] let dirs = p4Library.listDirs(depot) XCTAssert(dirs.count == 2, "Should be two dirs under //depot") XCTAssert(dirs.filter({$0.name == "notes"}).count > 0, "Did not find dir //depot/notes") XCTAssert(dirs.filter({$0.name == "reference"}).count > 0, "Did not find dir //depot/reference") } func testListFiles() { let p4Library = P4Library(settings: settings) let depot = p4Library.depots.filter({$0.name == "depot"})[0] let dirs = p4Library.listDirs(depot) let dir = dirs.filter({$0.name == "reference"})[0] let files = p4Library.listFiles(dir) XCTAssert(files.count == 2, "Should be two files in //depot/reference") XCTAssert(files.filter({$0.name == "Old Fashioned Ginger Snaps.doc"}).count > 0) XCTAssert(files.filter({$0.name == "Swift-Cheatsheet-0_3.pdf"}).count > 0) } }