Swift Package Index



  • The latest stable release is 0.1.5. Released over 1 year ago.
  • The last commit to master was over 1 year ago.

Swift Version Compatibility

  • 0.1.5 and master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 0.1.5 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

FluentTestUtils

Swift Vapor Swift Package Manager License

FluentTestUtils makes it easier to quickly setup a Fluent-based Vapor app for library testing purposes. If you have an existing Vapor app that you want to test, see VaporTestUtils.

Installation

FluentTestUtils is available through Swift Package Manager. To install, add the following to your Package.swift file.

let package = Package(
    name: "YourProject",
    dependencies: [
        ...
        .package(url: "https://github.com/Appsaurus/FluentTestUtils", from: "0.1.0"),
    ],
    targets: [
      .testTarget(name: "YourApp", dependencies: ["FluentTestUtils", ... ])
    ]
)
        

Usage

1. Import the library

import FluentTestUtils

2. Setup your test case

Create a test case inheriting from FluentTestCase.

Registering and configuration of services, databases, and migrations can be done via overriding register(services:), configure(databases:) and configure(migrations:) respectively.

open class ExampleAppTestCase: FluentTestCase{
	static var allTests = [
		("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests),		
		("testExample", testExample) //Reference your tests here for Linux check
	]

	func testLinuxTestSuiteIncludesAllTests(){
		assertLinuxTestCoverage(tests: type(of: self).allTests)
	}
	
	let sqlite: SQLiteDatabase = try! SQLiteDatabase(storage: .memory)
	
	open override func register(_ services: inout Services) throws {
		try super.register(&services)
		try services.register(FluentSQLiteProvider())
		services.register(sqlite)
	}
	
	open override func configure(databases: inout DatabasesConfig) throws{
		try super.configure(databases: &databases)
		databases.add(database: sqlite, as: .sqlite)
	}

	open override func configure(migrations: inout MigrationConfig){
		super.configure(migrations: &migrations)
		migrations.add(model: ExampleModel.self, database: .sqlite)
		migrations.add(model: ExampleSiblingModel.self, database: .sqlite)
		migrations.add(model: ExampleChildModel.self, database: .sqlite)
		migrations.add(model: ExampleModelSiblingPivot.self, database: .sqlite)
	}
	
	func testExample() {
		//Implement your test
	}
}

For futher documentation, see [VaporTestUtils] (https://github.com/Appsaurus/VaporTestUtils) as FluentTestCase inherits from that package's VaporTestCase.

Contributing

We would love you to contribute to FluentTestUtils, check the CONTRIBUTING file for more info.

License

FluentTestUtils is available under the MIT license. See the LICENSE file for more info.