#!/bin/bash

set -e
set -x

# Create test directory structure
TEST_DIR="$HOME/test-archive"
mkdir -p "$TEST_DIR"

echo "Created test directory: $TEST_DIR"

# Copy configuration
cp test-archive.conf /tmp/archive.conf
echo "Copied test configuration to /tmp/archive.conf"

# Export config location for archive script
export ARCHIVE_CONFIG=/tmp/archive.conf

# Run archive script with verbose output
echo "Starting archive sync..."
./archive.sh

# Test archive-cleaner
echo "Testing archive-cleaner..."
./archive-cleaner --repo "$TEST_DIR/repos/last" --archive "$TEST_DIR" --keep-years 1 