#!/usr/bin/env bash
set -euo pipefail

cd "$(git rev-parse --show-toplevel)"
if [[ ! -f "./cog" ]]; then
    echo "Could not find local cog binary. Please run \"make\" before re-running this script"
    exit 1
fi

cd "$(git rev-parse --show-toplevel)/test-integration/test_integration/fixtures/hello-image"
../../../../cog build

IMG_HASH=$(docker run --rm -it r8.im/replicate/hello-image:latest sha1sum predict.py | awk '{print $1}')
ORIG_HASH=$(sha1sum predict.py | awk '{print $1}')
if [[ "$IMG_HASH" != "$ORIG_HASH" ]]; then
  echo "Incorrect hash for predict.py, got $IMG_HASH. expected a15aa0c8c69714ce1610f28af525a2b102cb6510"
  exit 1
fi
echo "Success"
