include repo as text fixture, no need to clone from actual github
This commit is contained in:
parent
d123d627d4
commit
802ad84d30
25 changed files with 852 additions and 20 deletions
|
|
@ -42,12 +42,33 @@ This is standalone — it should be done before any other refactoring.
|
|||
|
||||
## Implementation
|
||||
|
||||
### 1. `PasswordStore` unit tests (highest priority)
|
||||
### 1. Fixture password-store repo
|
||||
|
||||
The single existing test (`testCloneAndDecryptMultiKeys`) depends on network access. Add offline unit tests using a local git repo fixture:
|
||||
A pre-built bare git repo checked into `passKitTests/Fixtures/password-store.git/`. Contains:
|
||||
|
||||
- **Setup/teardown**: Create a temp directory, `git init`, add `.gpg-id` + encrypted `.gpg` files, so tests don't need network.
|
||||
- **Test `initPasswordEntityCoreData`**: Clone a local fixture repo → verify correct `PasswordEntity` tree in Core Data (names, paths, directories, parent-child relationships).
|
||||
- A `.gpg-id` file with test key ID(s)
|
||||
- Several `.gpg` files encrypted with the test keys from `TestPGPKeys` (at various directory depths)
|
||||
- A subdirectory structure to exercise the BFS walk (nested folders, empty dirs)
|
||||
- A git history with at least a couple of commits
|
||||
|
||||
Since it's a bare repo, its contents (`HEAD`, `objects/`, `refs/`, etc.) are just regular files from the outer repo's perspective — no submodule issues.
|
||||
|
||||
**Xcode project setup**: The fixture directory must be added to the Xcode project as a **folder reference** (blue folder) in the passKitTests target, and with "Build Rules" set to "Apply Once to Folder", so it's included in the "Copy Bundle Resources" build phase. In Xcode: drag the `Fixtures/` directory into the passKitTests group → select "Create folder references" → check only the passKitTests target. Without this, the files won't be accessible from the test bundle at runtime.
|
||||
|
||||
To update the fixture, pull from origin (already set to `https://github.com/mssun/passforios-password-store.git`) or replace with any local bare repo:
|
||||
```sh
|
||||
# Update from origin
|
||||
cd passKitTests/Fixtures/password-store.git
|
||||
git fetch origin
|
||||
git update-ref refs/heads/master origin/master
|
||||
|
||||
# Or replace with a custom local repo
|
||||
git clone --bare /path/to/local/repo passKitTests/Fixtures/password-store.git
|
||||
```
|
||||
|
||||
### 2. `PasswordStore` unit tests (highest priority)
|
||||
|
||||
- **Test `initPasswordEntityCoreData`**: Clone the fixture repo → verify correct `PasswordEntity` tree in Core Data (names, paths, directories, parent-child relationships).
|
||||
- **Test `deleteCoreData`**: Populate, then delete, verify empty.
|
||||
- **Test `eraseStoreData`**: Verify repo directory deleted, Core Data cleared, git handle nil'd.
|
||||
- **Test `erase`**: Verify full cleanup (keychain, defaults, passcode, PGP state).
|
||||
|
|
@ -56,7 +77,7 @@ The single existing test (`testCloneAndDecryptMultiKeys`) depends on network acc
|
|||
- **Test `add` / `delete` / `edit`**: Verify filesystem + Core Data + git commit.
|
||||
- **Test `reset`**: Verify Core Data rebuilt to match filesystem after git reset.
|
||||
|
||||
### 2. `PasswordEntity` relationship tests
|
||||
### 3. `PasswordEntity` relationship tests
|
||||
|
||||
Extend `PasswordEntityTest` (already uses `CoreDataTestCase`):
|
||||
|
||||
|
|
@ -65,7 +86,7 @@ Extend `PasswordEntityTest` (already uses `CoreDataTestCase`):
|
|||
- **Test hidden files are skipped**.
|
||||
- **Test empty directories**.
|
||||
|
||||
### 3. `AppKeychain` tests
|
||||
### 4. `AppKeychain` tests
|
||||
|
||||
Basic tests against the real Keychain API (or a test wrapper):
|
||||
|
||||
|
|
@ -74,25 +95,21 @@ Basic tests against the real Keychain API (or a test wrapper):
|
|||
- **Test `contains`**.
|
||||
- **Test `removeAllContent(withPrefix:)`** — this method already exists and will be useful for per-store cleanup.
|
||||
|
||||
### 4. `PersistenceController` tests
|
||||
### 5. `PersistenceController` tests
|
||||
|
||||
- **Test `reinitializePersistentStore`** — verify existing data is gone after reinit.
|
||||
- **Test model loading** — verify the `.momd` loads correctly.
|
||||
|
||||
### 5. Test infrastructure: local git repo fixture builder
|
||||
|
||||
A helper that creates a temp git repo with configurable `.gpg-id`, encrypted `.gpg` files, and directory structure. Replaces the current network-dependent clone in `PasswordStoreTest`.
|
||||
|
||||
---
|
||||
|
||||
## Implementation Order
|
||||
|
||||
All steps are independent and can be done in parallel:
|
||||
|
||||
| Step | Description |
|
||||
|------|-------------|
|
||||
| 1 | `PasswordStore` unit tests (offline, local git fixture) |
|
||||
| 2 | `PasswordEntity` BFS walk + relationship tests |
|
||||
| 3 | `AppKeychain` tests |
|
||||
| 4 | `PersistenceController` tests |
|
||||
| 5 | Local git repo fixture builder (prerequisite for step 1) |
|
||||
| 1 | Fixture password-store bare repo |
|
||||
| 2 | `PasswordStore` unit tests (uses fixture from step 1) |
|
||||
| 3 | `PasswordEntity` BFS walk + relationship tests |
|
||||
| 4 | `AppKeychain` tests |
|
||||
| 5 | `PersistenceController` tests |
|
||||
|
||||
Steps 2–5 can be done in parallel once step 1 is complete. Steps 3–5 are also independent of step 1.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue