# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "picopackage" require "minitest/autorun" require "tmpdir" module PicopackageTest # Every test gets its own cache root: the merge base cache is global state and # a suite that shared one would pass or fail depending on what ran before it. def with_dirs Dir.mktmpdir("picopackage-test") do |root| upstream = File.join(root, "upstream") project = File.join(root, "project") [upstream, project].each { |dir| Dir.mkdir(dir) } yield(upstream, project, Picopackage::Cache.new(root: File.join(root, "cache"))) end end # Stands in for a server: a real file, fetched through the real FileProvider, # so provider metadata population is exercised rather than faked. def publish(dir, name, content) path = File.join(dir, name) File.write(path, content) path end def upstream_package(path) Picopackage::FileProvider.new(path).package end end