#!/bin/bash

set -euo pipefail

function assert_file_contents {
  file="ci/example_tests/test_tar_dir/files/$1"
  expected_contents=$2
  actual_contents=$(< "$file")

  if [[ $actual_contents != $expected_contents ]]; then
    echo "FAILED: $file contents is $actual_contents (expected $expected_contents)"
    exit 1
  fi
}

assert_file_contents root root
assert_file_contents 1/one one
assert_file_contents 2/two two

if [ -f ci/example_tests/test_tar_dir/files/3/three ]; then
  echo ci/example_tests/test_tar_dir/files/3/three exists but should not
  echo Contents of ci/example_tests/test_tar_dir:
  find -L ci/example_tests/test_tar_dir
  exit 1
fi
