From 26619f2ee1a022ec5aa4f9e46bf2417e8486086d Mon Sep 17 00:00:00 2001 From: Cody Kerns Date: Wed, 21 Feb 2024 23:12:17 -0500 Subject: [PATCH] fix tests --- Sources/StableID/StableID.swift | 2 +- Tests/StableIDTests/StableIDTests.swift | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Sources/StableID/StableID.swift b/Sources/StableID/StableID.swift index 02ba9c9..b46c69b 100644 --- a/Sources/StableID/StableID.swift +++ b/Sources/StableID/StableID.swift @@ -8,7 +8,7 @@ import Foundation public class StableID { - private static var _stableID: StableID? = nil + internal static var _stableID: StableID? = nil private static var shared: StableID { guard let _stableID else { diff --git a/Tests/StableIDTests/StableIDTests.swift b/Tests/StableIDTests/StableIDTests.swift index 5d059c1..fc92ff2 100644 --- a/Tests/StableIDTests/StableIDTests.swift +++ b/Tests/StableIDTests/StableIDTests.swift @@ -12,7 +12,7 @@ final class StableIDTests: XCTestCase { func clearDefaults() { guard let defaults = UserDefaults(suiteName: Constants.StableID_Key_DefaultsSuiteName) else { return } - + let dictionary = defaults.dictionaryRepresentation() dictionary.keys.forEach { key in print(key) @@ -20,16 +20,24 @@ final class StableIDTests: XCTestCase { } } - func testConfiguring() { + override func setUp() { + super.setUp() + clearDefaults() + } + + override func tearDown() { + super.tearDown() + + StableID._stableID = nil + } + func testConfiguring() { StableID.configure() XCTAssert(StableID.isConfigured == true) } func testIdentifying() { - clearDefaults() - StableID.configure() let uuid = UUID().uuidString @@ -39,8 +47,6 @@ final class StableIDTests: XCTestCase { } func testGenerateNewID() { - clearDefaults() - StableID.configure() let originalID = StableID.id @@ -51,8 +57,6 @@ final class StableIDTests: XCTestCase { } func testShortIDLength() { - clearDefaults() - StableID.configure(idGenerator: StableID.ShortIDGenerator()) XCTAssert(StableID.id.count == 8)