From d2b539be041a022c580712a96e61cc7807647bda Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Tue, 17 Dec 2024 20:32:16 +0800 Subject: [PATCH] feat: improve code format --- Package.swift | 3 --- Tests/CasbinTests/ConfigTests.swift | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Package.swift b/Package.swift index ed47279..2e327e6 100644 --- a/Package.swift +++ b/Package.swift @@ -33,11 +33,8 @@ let package = Package( .product(name: "Regex", package: "Regex"), .product(name: "NIO", package: "swift-nio"), .product(name: "NIOTransportServices", package: "swift-nio-transport-services") - ] - ), - .testTarget( name: "CasbinTests", dependencies: ["Casbin"], diff --git a/Tests/CasbinTests/ConfigTests.swift b/Tests/CasbinTests/ConfigTests.swift index 480d2e8..4886e9d 100644 --- a/Tests/CasbinTests/ConfigTests.swift +++ b/Tests/CasbinTests/ConfigTests.swift @@ -11,16 +11,16 @@ final class ConfigTests: XCTestCase { try pool.syncShutdownGracefully() try elg.syncShutdownGracefully() } catch { - } } + func testGet() throws { let filePath = #file.components(separatedBy: "ConfigTests.swift")[0] + "examples/testini.ini" pool.start() let fileIo = NonBlockingFileIO(threadPool: pool) var config = try Config.from(file: filePath, fileIo: fileIo, on: elg.next()) .wait() - + XCTAssertEqual(true, config.getBool(key: "debug")) XCTAssertEqual(64, config.getInt(key: "math::math.i64")) XCTAssertEqual(64.1, config.getFloat(key: "math::math.f64")) @@ -37,7 +37,7 @@ final class ConfigTests: XCTestCase { try pool.syncShutdownGracefully() try elg.syncShutdownGracefully() } - + func testFromText() throws { let text = #""" # test config @@ -61,7 +61,7 @@ final class ConfigTests: XCTestCase { math.i64 = 64 math.f64 = 64.1 """# - + var config = try Config.from(text: text, on: elg.next()).wait() XCTAssertEqual(true, config.getBool(key: "debug")) XCTAssertEqual(64, config.getInt(key: "math::math.i64")) @@ -71,7 +71,7 @@ final class ConfigTests: XCTestCase { XCTAssertEqual("new test key", config.get(key: "other::key1")) config.set(key: "other::key1", value: "test key") XCTAssertEqual("test key", config.get(key: "other::key1")) - + try pool.syncShutdownGracefully() try elg.syncShutdownGracefully() }