<commit_before>//
//  TreasureDataSwiftTests.swift
//  TreasureDataTests
//
//  Created by <NAME> on 1/27/19.
//  Copyright © 2019 <NAME>. All rights reserved.
//

import XCTest

class IntegrationTests: XCTestCase {

    var sdkClient: TreasureData!
    static var api: TDAPI!
    static var apiKey: String!

    static let TargetDatabase = "ios_it"
    static var sessionPrefix = uuid()

    /** Tables used in a single test */
    var tempTables: [String] = []

    override class func setUp() {
        apiKey = ProcessInfo.processInfo.environment["API_MASTER_KEY"]
        apiEndpoint = ProcessInfo.processInfo.environment["API_ENDPOINT"]

        api = TDAPI.init(endpoint: "API_ENDPOINT", apiKey: apiKey)
        if (!(try! api.isDatabaseExist(TargetDatabase))) {
            fatalError("Either the apiKey is invalid or the target database \(TargetDatabase) is not exist!")
        }
    }

    override class func tearDown() {
        IntegrationTests.api = nil
    }

    override func setUp() {
        TreasureData.initializeApiEndpoint("https://in-development.treasuredata.com")
        sdkClient = TreasureData(apiKey: IntegrationTests.apiKey)
        sdkClient.defaultDatabase = IntegrationTests.TargetDatabase
        tempTables = []
    }

    override func tearDown() {
        let remoteTables = Set<String>(IntegrationTests.api.listTables(database: IntegrationTests.TargetDatabase))
        for sessionTable in tempTables {
            if remoteTables.contains(sessionTable) {
                try! IntegrationTests.api.deleteTable(database: IntegrationTests.TargetDatabase, table: sessionTable)
            } else {
                print("WARN: Skip deleting table '\(IntegrationTests.TargetDatabase).\(sessionTable)' as it is not exist!")
            }<commit_msg>Add some early checks of env variables on tests<commit_after>//
//  TreasureDataSwiftTests.swift
//  TreasureDataTests
//
//  Created by <NAME> on 1/27/19.
//  Copyright © 2019 <NAME>. All rights reserved.
//

import XCTest

class IntegrationTests: XCTestCase {

    var sdkClient: TreasureData!
    static var api: TDAPI!
    static var apiKey: String!

    static let TargetDatabase = "ios_it"
    static var sessionPrefix = uuid()

    /** Tables used in a single test */
    var tempTables: [String] = []

    override class func setUp() {
        guard let apiKey = ProcessInfo.processInfo.environment["API_MASTER_KEY"] else {
            fatalError("Missing env API_MASTER_KEY")
        }
        guard let apiEndpoint = ProcessInfo.processInfo.environment["API_ENDPOINT"] else {
            fatalError("Missing env API_ENDPOINT")
        }

        IntegrationTests.apiKey = apiKey
        api = TDAPI.init(endpoint: apiEndpoint, apiKey: apiKey)
        if (!(try! api.isDatabaseExist(TargetDatabase))) {
            fatalError("Either the apiKey is invalid or the target database \(TargetDatabase) is not exist!")
        }
    }

    override class func tearDown() {
        IntegrationTests.api = nil
    }

    override func setUp() {
        TreasureData.initializeApiEndpoint("https://in-development.treasuredata.com")
        sdkClient = TreasureData(apiKey: IntegrationTests.apiKey)
        sdkClient.defaultDatabase = IntegrationTests.TargetDatabase
        tempTables = []
    }

    override func tearDown() {
        let remoteTables = Set<String>(IntegrationTests.api.listTables(database: IntegrationTests.TargetDatabase))
        for sessionTable in tempTables {
            if remoteTables.contains(sessionTable) {
                try! IntegrationTests.api.deleteTable(database: IntegrationTests.TargetDatabase, table: sessionTable)
            } else {
                print("WARN: Skip deleting table '\(IntegrationTests.TargetDatabase).\(sessionTable)' as it is not exist!")
            }
{'fraction_non_alphanumeric': 0.09694415173867228, 'fraction_numerical': 0.004741833508956797, 'mean_word_length': 2.8626653102746693, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '6331581', 'n_tokens_mistral': 1065, 'n_tokens_neox': 997, 'n_words': 266}