Files
Dan MilneandClaude Fable 5 6dd57e84f1 Version 0.3.0: resolver/merge/cache refactor, signing design notes
- Split the monolith into package/provider/fetch/merge/cache modules with
  the Resolver deciding install/adopt/update/merge/conflict outcomes
- Three-way merges via git merge-file/diff3 against a content-addressed
  merge-base cache; conflicts go to a .picopackage-merge sibling
- Tests for package, provider, resolver, merge, and cache
- notes.md: update UX and signing design — diff-by-default, SSH signature
  identity pinning (TOFU), key changes as a hard stop, exit-code contract
- Add CLAUDE.md; remove the pre-refactor exe/pppkg monolith and scratch files

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EiyJC73Mz8xZyCTvCEY8qn
2026-08-13 21:18:19 +10:00

37 lines
984 B
Ruby

# frozen_string_literal: true
require "test_helper"
class TestCache < Minitest::Test
def with_cache
Dir.mktmpdir("picopackage-cache") { |root| yield Picopackage::Cache.new(root: root) }
end
def test_stores_and_fetches_by_content
with_cache do |cache|
checksum = cache.store("hello\n")
assert_equal Picopackage::Payload.checksum("hello\n"), checksum
assert_equal "hello\n", cache.fetch(checksum)
end
end
def test_storing_twice_is_harmless
with_cache do |cache|
a = cache.store("hello\n")
b = cache.store("hello\n")
assert_equal a, b
assert_equal "hello\n", cache.fetch(a)
end
end
def test_unknown_and_malformed_checksums_return_nil
with_cache do |cache|
assert_nil cache.fetch(Picopackage::Payload.checksum("never stored"))
assert_nil cache.fetch(nil)
assert_nil cache.fetch("")
assert_nil cache.fetch("sha256:../../escape")
refute cache.include?(nil)
end
end
end