From 1b3fa77435d5552fbd488bbb93c12631071f6c4f Mon Sep 17 00:00:00 2001 From: Casper Rasmussen Date: Thu, 29 Dec 2016 22:26:28 +0100 Subject: [PATCH] added first test for schema creator --- Package.swift | 3 ++- Tests/LinuxMain.swift | 1 + Tests/SugarTests/CreatorMySQLTests.swift | 26 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 Tests/SugarTests/CreatorMySQLTests.swift diff --git a/Package.swift b/Package.swift index 7cd8ded..6ab5b4c 100644 --- a/Package.swift +++ b/Package.swift @@ -3,6 +3,7 @@ import PackageDescription let package = Package( name: "Sugar", dependencies: [ - .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1) + .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1), + .Package(url: "https://github.com/vapor/mysql-provider.git", majorVersion: 1, minor: 1) ] ) diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index 2b7a5d3..ba32051 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -3,4 +3,5 @@ import XCTest XCTMain([ testCase(DateSugarTests.allTests), + testCase(CreatorMySQLTests.allTests), ]) diff --git a/Tests/SugarTests/CreatorMySQLTests.swift b/Tests/SugarTests/CreatorMySQLTests.swift new file mode 100644 index 0000000..b7fc425 --- /dev/null +++ b/Tests/SugarTests/CreatorMySQLTests.swift @@ -0,0 +1,26 @@ +import XCTest +import Fluent + +@testable import Sugar + +class CreatorMySQLTests: XCTestCase { + + func testString() { + let builder = Schema.Creator("table") + builder.string("string") + + let sql = builder.schema.sql + let serializer = GeneralSQLSerializer(sql: sql) + + let (statement, values) = serializer.serialize() + + XCTAssertEqual(statement, "CREATE TABLE `table` (`string` STRING NOT NULL)") + XCTAssertEqual(values.count, 0) + } + + static var allTests : [(String, (CreatorMySQLTests) -> () throws -> Void)] { + return [ + ("testString", testString), + ] + } +}