#!/bin/sh

APISNAP=api.snap.txt

./scripts/staged_files_match './scripts/**' 'core/**/*.go' && ./scripts/api_snapshot ./core > core/$APISNAP

if ! git diff --quiet core/$APISNAP; then
  echo "There are unstaged changes to $APISNAP"
  exit 1
fi

if ./scripts/staged_files_match 'assert/**' 'core/**/*'; then
  go test ./core/... || {
    echo "./core test failure"
    exit 1
  }
fi

if ./scripts/staged_files_match 'assert/**' 'http/props/htmlx/**/*.go'; then
  go test ./http/props/htmlx/... || {
    echo "./http test failure"
    exit 1
  }
fi
