Skip to content

Commit

Permalink
Enhance constructor error message in case the default value is missing (
Browse files Browse the repository at this point in the history
#31)

* Enhance constructor error message in case the default value is missing

* Delete unneeded overriden functions in test cases
  • Loading branch information
PierreMardon authored Aug 23, 2023
1 parent 57333e3 commit 6fac510
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 13 deletions.
2 changes: 1 addition & 1 deletion Sources/PDefaults/PDefaults+Init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public extension PDefaults {
}

/// Constructor catching all type errors to expose compatibility constraints message
@available(*, unavailable, message: "You can use PDefaults only types that either conform to Codable or are natively handled by UserDefaults")
@available(*, unavailable, message: "You have to provide a default value or use an optional type. In the latter case, make sure the type either conforms to Codable or is natively handled by UserDefaults")
// swiftlint:disable:previous line_length
convenience init(_ key: String,
suite: UserDefaults = .standard,
Expand Down
4 changes: 0 additions & 4 deletions Tests/PDefaultsTests/TestMigration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class TestMigration: XCTestCase {
PDefaultsConfiguration.mock = false
}

override func tearDown() {
super.tearDown()
}

func testNominalMigration() {
let value = 1
let source = PDefaults<Int?>(wrappedValue: nil, sourceKey)
Expand Down
4 changes: 0 additions & 4 deletions Tests/PDefaultsTests/TestPublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class TestPublisher: XCTestCase {
PDefaultsConfiguration.mock = false
}

override func tearDown() {
super.tearDown()
}

func testClosureCalledOnSink() {
let pdefaults = PDefaults(wrappedValue: 1, key, suite: suite)
let expectCalled = expectation(description: "PDefaults publisher sink closure is expected to be called on"
Expand Down
4 changes: 0 additions & 4 deletions Tests/PDefaultsTests/TestStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class TestStorage: XCTestCase {
PDefaultsConfiguration.mock = false
}

override func tearDown() {
super.tearDown()
}

func testNoStorageWhenNotNeeded() {
let pDefaults = PDefaults(wrappedValue: Optional.some(1), key, suite: suite)
XCTAssert(suite.object(forKey: key) == nil, "Storage should not contain a value for key \"\(key)\"")
Expand Down

0 comments on commit 6fac510

Please sign in to comment.