<commit_before> //
//  DatabaseTests.swift
//  MongoKitten
//
//  Created by <NAME> on 21/04/16.
//
//

import XCTest
@testable import MongoKitten
import BSON

class AdministrationCommandsTests: XCTestCase {
    static var allTests: [(String, (AdministrationCommandsTests) -> () throws -> Void)] {
        return [
                   ("testServer", testServer),
                   ("testDatabase", testDatabase),
                   ("testCollection", testCollection),
        ]
    }
    
    override func setUp() {
        super.setUp()
        
        try! TestManager.clean()
    }  
    
    override func tearDown() {
        try! TestManager.disconnect()
    }
    
    func testServer() throws {
        XCTAssert(TestManager.server.isConnected)
        
        try TestManager.server.fsync()
        let dbs = try TestManager.server.getDatabases()
        
        var dbExists = false
        
        for db in dbs where db.name == "mongokitten-unittest" {
           dbExists = true
        }
        
        XCTAssertEqual(TestManager.server.hostname, "mongodb://localhost:27017")
        
        XCTAssert(dbExists)
        
        try TestManager.db.copy(toDatabase: "mongokitten-unittest-temp")<commit_msg>Fixed the test with an alternative mongoURL<commit_after> //
//  DatabaseTests.swift
//  MongoKitten
//
//  Created by <NAME> on 21/04/16.
//
//

import XCTest
@testable import MongoKitten
import BSON

class AdministrationCommandsTests: XCTestCase {
    static var allTests: [(String, (AdministrationCommandsTests) -> () throws -> Void)] {
        return [
                   ("testServer", testServer),
                   ("testDatabase", testDatabase),
                   ("testCollection", testCollection),
        ]
    }
    
    override func setUp() {
        super.setUp()
        
        try! TestManager.clean()
    }  
    
    override func tearDown() {
        try! TestManager.disconnect()
    }
    
    func testServer() throws {
        XCTAssert(TestManager.server.isConnected)
        
        try TestManager.server.fsync()
        let dbs = try TestManager.server.getDatabases()
        
        var dbExists = false
        
        for db in dbs where db.name == "mongokitten-unittest" {
           dbExists = true
        }
        
        XCTAssert(dbExists)
        
        try TestManager.db.copy(toDatabase: "mongokitten-unittest-temp")
{'fraction_non_alphanumeric': 0.10317460317460317, 'fraction_numerical': 0.007101086048454469, 'mean_word_length': 1.8511904761904763, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '976896', 'n_tokens_mistral': 702, 'n_tokens_neox': 678, 'n_words': 145}