Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #2

Merged
merged 4 commits into from
Feb 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix tests
codykerns committed Feb 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 26619f2ee1a022ec5aa4f9e46bf2417e8486086d
2 changes: 1 addition & 1 deletion Sources/StableID/StableID.swift
Original file line number Diff line number Diff line change
@@ -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 {
20 changes: 12 additions & 8 deletions Tests/StableIDTests/StableIDTests.swift
Original file line number Diff line number Diff line change
@@ -12,24 +12,32 @@ 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)
defaults.removeObject(forKey: key)
}
}

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)