Update test scripts to account for cwd

This commit is contained in:
Tim Van Baak 2025-02-24 12:03:14 -08:00
parent f39f525294
commit f2ab5ac6d5
4 changed files with 21 additions and 6 deletions

3
.envrc
View File

@ -1,5 +1,6 @@
layout go
use flake
export INTAKE_DATA_DIR=tmp
rootPath=$(dirname $(dirname $(realpath "$0")))
export INTAKE_DATA_DIR=$(expand_path tmp)
unset AR AS CC CONFIG_SHELL CXX HOST_PATH LD NIX_BINTOOLS NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu NIX_BUILD_CORES NIX_CC NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu NIX_CFLAGS_COMPILE NIX_ENFORCE_NO_NATIVE NIX_HARDENING_ENABLE NIX_LDFLAGS NIX_STORE NM OBJCOPY OBJDUMP RANLIB READELF SIZE SOURCE_DATE_EPOCH STRINGS STRIP __structuredAttrs buildInputs buildPhase builder cmakeFlags configureFlags depsBuildBuild depsBuildBuildPropagated depsBuildTarget depsBuildTargetPropagated depsHostHost depsHostHostPropagated depsTargetTarget depsTargetTargetPropagated doCheck doInstallCheck dontAddDisableDepTrack mesonFlags name nativeBuildInputs out outputs patches phases preferLocalBuild propagatedBuildInputs propagatedNativeBuildInputs shell shellHook stdenv strictDeps system

View File

@ -1,10 +1,16 @@
.PHONY: help serve test-data demo
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
help: ## display this help
@awk 'BEGIN{FS = ":.*##"; printf "\033[1m\nUsage\n \033[1;92m make\033[0;36m <target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } ' $(MAKEFILE_LIST)
serve: ## Run "intake serve" with live reload
@air -build.cmd "go build -o tmp/intake" -build.bin tmp/intake -build.args_bin serve,--data-dir,tmp -build.include_ext "go,html,css"
@air \
-build.cmd "go build -o ${ROOT_DIR}/tmp/intake" \
-build.bin ${ROOT_DIR}/tmp/intake \
-build.args_bin serve \
-build.include_ext "go,html,css"
test-data: ## Recreate test data in tmp/
@test/test_items.sh

5
test/hello.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
cat /dev/random \
| base32 \
| head -c8 \
| jq -cR '{id: ., title: "Hello"}'

View File

@ -1,9 +1,12 @@
#!/usr/bin/env bash
set -eu
go build -o tmp/intake
rm tmp/intake.db* || true
export INTAKE_DATA_DIR="tmp"
rootPath=$(dirname $(dirname $(realpath "$0")))
rm -v "$rootPath"/tmp/intake.db* || true
cp -v "$rootPath"/test/*.sh "$rootPath/tmp/"
go build -o "$rootPath/tmp/intake"
export INTAKE_DATA_DIR="$rootPath/tmp"
tmp/intake migrate
# testing item display format
@ -57,7 +60,7 @@ tmp/intake item add -s page --id 212 --title "Item 212" --body "This is the body
# test auto update
tmp/intake source env -s nothing --set "INTAKE_FETCH=every 5m"
tmp/intake source add -s hello
tmp/intake action add -s hello -a fetch -- sh -c "cat /dev/random | base32 | head -c8 | jq -cR '{id: ., title: \"Hello\"}'"
tmp/intake action add -s hello -a fetch -- ./hello.sh
tmp/intake source env -s hello --set "INTAKE_FETCH=every 1m"
# and batch
tmp/intake source env -s hello --set "INTAKE_BATCH=00:00"