feat: add dict preference model#1
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for storing and retrieving dictionary preferences ([String: Any]) across the adapter, getter, setter, and provider layers, and introduces corresponding tests.
- Added
getDict/setDictmethods toUserDefaultPreferenceAdapter, its getter/setter adapters, providers, and protocols. - Extended test doubles and test suites to cover dictionary operations.
- Updated
Package.swiftto reference branch “main” for dependencies.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/.../UserDefaultPreferenceSetterAdapterTests.swift | Added SetDictTests to verify setDict behavior. |
| Tests/.../UserDefaultPreferenceGetterAdapterTests.swift | Renamed suites/tests and added DictTests for getDict. |
| Tests/.../UserDefaultPreferenceAdapterTests.swift | Added DictTests and SetDictTests for adapter. |
| Tests/.../Doubles/PreferenceSetterDouble.swift | Added setDictMocked and expectDict. |
| Tests/.../Doubles/PreferenceGetterDouble.swift | Added getDictMocked. |
| Sources/.../UserDefaultPreferenceAdapter.swift | Implemented getDict/setDict methods and docs. |
| Sources/.../PreferenceSetterProvider.swift | Added setDict support in UserDefaultPreferenceSetterAdapter. |
| Sources/.../PreferenceGetterProvider.swift | Added getDict support in UserDefaultPreferenceGetterAdapter. |
| Sources/.../PreferenceSetter.swift & PreferenceGetter.swift & Preference.swift | Extended protocols to include dictionary methods. |
| Package.swift | Changed dependencies to track main branches. |
Comments suppressed due to low confidence (4)
Tests/EasyUserDefaultPreferenceTests/UserDefaultPreferenceAdapterTests.swift:207
- The suite annotation
.getDict(value:)doesn’t match the method signaturegetDict(_ key:). Rename it to.getDict(key:)to reflect the correct parameter name.
@Suite(".getDict(value:)")
Tests/EasyUserDefaultPreferenceTests/UserDefaultPreferenceGetterAdapterTests.swift:66
- This suite is for
IntTestsbut references.getBool(key:). It should be.getInt(key:)to match the tested method.
@Suite(".getBool(key:)")
Tests/EasyUserDefaultPreferenceTests/UserDefaultPreferenceGetterAdapterTests.swift:254
- [nitpick] The test description mentions
truebut is testing dictionary retrieval. Update it to something likeshould return stored dictionary when present.
@Test("should return when true is stored")
Tests/EasyUserDefaultPreferenceTests/UserDefaultPreferenceGetterAdapterTests.swift:262
- [nitpick] The test description refers to
falsebut actually validates a dictionary. Rename to clarify it's testing a different dictionary value.
@Test("should return other data when false is stored")
| branch: "main" | ||
| ), | ||
| .package(path: "../EasyTesting") | ||
| .package( | ||
| url: "https://github.com/EasyPackages/EasyTesting.git", | ||
| branch: "main" |
There was a problem hiding this comment.
Pinning dependencies to the main branch can introduce instability. Consider using a version-based requirement to ensure reproducible builds.
Description
Type of change
Checklist:
Evidence