diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-18 10:40:18 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-18 10:40:18 +0200 |
| commit | e54d9405dd818cd3ee7c203b8ec1d21713470904 (patch) | |
| tree | 5b7afeff3bcec5c79c9aee4c9a1d09bc610fe3eb /test/test_data.lua | |
| parent | 7f14e983c2ed73f69dbdd7bb155203a0762b814a (diff) | |
| download | conky-theme-udt-e54d9405dd818cd3ee7c203b8ec1d21713470904.tar.gz conky-theme-udt-e54d9405dd818cd3ee7c203b8ec1d21713470904.zip | |
feat: the cache and slackware cards move to quickshell
Both cards are now drawn by quickshell, so the conky copies go: the two
widgets, their samplers and texeci lines, their fixtures and icons, and
du_parse with human_bytes, which only the cache card used. kv_parse stays
for breaktimer; its test now runs on an inline string. README gains a
Samplers section listing what conky still schedules, and DESIGN.md's
examples point at the cards that remain. Their slots in the layout are
left open.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'test/test_data.lua')
| -rw-r--r-- | test/test_data.lua | 38 |
1 files changed, 4 insertions, 34 deletions
diff --git a/test/test_data.lua b/test/test_data.lua index df6775b..9066241 100644 --- a/test/test_data.lua +++ b/test/test_data.lua @@ -20,30 +20,6 @@ local function read(path) return s end --- === Cache files ========================================================== --- du -sh: total first, then children largest-first. The suffixes must be --- converted, not string-sorted: '1.1G' outranks '245M' numerically and loses --- to it alphabetically. -local cache = data.du_parse(read('test/fixtures/du_output')) -assert(cache.total, 'a total is parsed') -assert(cache.total.label == '1.6G', 'total label, got ' .. tostring(cache.total.label)) -assert(#cache.items == 4, 'four children, got ' .. tostring(#cache.items)) -assert(cache.items[1].name == 'mozilla', 'largest child, got ' .. tostring(cache.items[1].name)) -assert(cache.items[1].label == '1.1G', 'its label, got ' .. tostring(cache.items[1].label)) -assert(cache.items[2].name == 'pip', 'second child, got ' .. tostring(cache.items[2].name)) - --- Sizes are compared as bytes, which is what makes 'biggest' meaningful. -assert(cache.items[1].bytes > cache.items[2].bytes, '1.1G must outrank 245M') -assert(cache.items[1].bytes > 1e9, 'a G suffix is about a billion bytes') -assert(cache.items[4].bytes < 1e8, 'an M suffix is far smaller') - --- Share of the total drives the highlight colour. -assert(cache.items[1].bytes / cache.total.bytes > 0.5, - 'mozilla dominates this fixture, which is what the highlight keys on') - -assert(data.du_parse('') == nil, 'empty input gives nil') -assert(data.du_parse(nil) == nil, 'nil gives nil') - -- === card.truncate ======================================================== -- Truncation is by CHARACTER, not byte: slicing a UTF-8 string mid-sequence -- emits an invalid byte that Cairo draws as a replacement box, and the name @@ -66,16 +42,10 @@ assert(card.truncate(nil, 10) == '', 'nil truncates to empty') assert(card.truncate('abc', 0) == '', 'a zero limit gives empty') -- === kv_parse ============================================================= --- The slackware sampler writes 'key value' lines. The format is deliberately --- dumber than the data: epochs stay integers rather than becoming formatted --- dates, so the widget decides how to render an age and the shell never --- reconstructs a date string. -local kv = data.kv_parse(read('test/fixtures/slackware_cache')) -assert(kv.version == 'Slackware 15.0+', 'version, got ' .. tostring(kv.version)) --- The value keeps its internal spaces: only the FIRST space is the separator. -assert(kv.packages == '1234', 'packages, got ' .. tostring(kv.packages)) -assert(kv.changelog == '1758000000', 'changelog, got ' .. tostring(kv.changelog)) -assert(kv.kernel == '6.12.1', 'kernel, got ' .. tostring(kv.kernel)) +-- Samplers write 'key value' lines; only the FIRST space is the separator. +local kv = data.kv_parse('title Long break\nremain 125\n') +assert(kv.title == 'Long break', 'value keeps its spaces, got ' .. tostring(kv.title)) +assert(kv.remain == '125', 'remain, got ' .. tostring(kv.remain)) -- A key the sampler did not write reads nil, which is how the widget tells -- "the sampler ran but this fact was unavailable" from "no sampler". |
