Commit f9d3fbc
Add tests for absent anonymizer and residential data
horgh's review of the anonymizer.residential addition flagged two
untested paths:
- Insights#initialize unconditionally calls
Anonymizer.new(record['anonymizer']), and Anonymizer#initialize
unconditionally calls AnonymizerFeed.new(record['residential']). The
common case has neither key present, so Anonymizer.new(nil) and
AnonymizerFeed.new(nil) are the hot paths, guarded only by
`record.nil? ? nil : record['residential']`. Add coverage for a
Model::Insights built from a raw hash with no "anonymizer" key at
all, and for an "anonymizer" present without a nested "residential"
key, asserting every getter returns nil with no NoMethodError.
- network_last_seen's `if !date_string` guard, which prevents
Date.parse(nil) from raising when the date key is absent, was
untested in all three places it is duplicated: AnonymizerFeed,
Anonymizer, and Model::AnonymousPlus. Add a test per class
asserting network_last_seen is nil when the date key is absent.
Verified the AnonymizerFeed test actually catches a regression: with
the guard temporarily removed (network_last_seen calling
Date.parse(date_string) unconditionally), 3 of the 5 new tests failed
with "TypeError: no implicit conversion of nil into String" as
expected. Restored the guard afterward.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 39e1d6f commit f9d3fbc
1 file changed
Lines changed: 79 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
0 commit comments