#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
go version
go env GOOS GOARCH CGO_ENABLED
go test -count=1 -v ./...
go test -race -count=1 ./...
go vet ./...
go run . -config config.json
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
printf '%s\n' '{"retention_day":7}' > "$tmp/bad.json"
set +e
go run . -config "$tmp/bad.json"
code=$?
set -e
printf 'unknown_field_exit=%s\n' "$code"
test "$code" -ne 0
