test: add 18 tests for 0.3 features
CI / build-and-test (push) Successful in 38s

- 8 tests: --features and --config flags (add, update, idempotent, file verification)
- 3 tests: transitive dependency resolution (auto-resolve chain)
- 4 tests: kappa search (name, substring, repo source, no-match)
- 3 tests: kappa upgrade (detection, version display, dry-run)

Total: 85 → 103 in test-full.sh (30+23+103 = 156 overall)
This commit is contained in:
2026-08-05 07:42:59 -04:00
parent 01fcb20a57
commit d918f7b6fc
+147
View File
@@ -521,6 +521,39 @@ check_fail "remove needs name" \
"$KAPPA remove" \ "$KAPPA remove" \
'no package name' 'no package name'
# --features and --config flags
check "add with --features" \
"$KAPPA add featpkg --features 'ssl=on,gzip=off'" \
'added featpkg'
check "add features present in config" \
"grep -c 'ssl = true' $KAPPA_ROOT/system/config.kap" \
'1'
check "update existing with --features" \
"$KAPPA add featpkg --features 'http2=on'" \
'updated featpkg'
check "add with --config" \
"$KAPPA add cfgpkg --config 'port=9090,worker=4'" \
'added cfgpkg'
check "config values written to file" \
"grep 'port = 9090' $KAPPA_ROOT/system/config.kap" \
'port = 9090'
check "add with features and config together" \
"$KAPPA add combopkg --features 'ssl=on' --config 'host=localhost'" \
'added combopkg'
check "features and config both in file" \
"grep -c ssl $KAPPA_ROOT/system/config.kap" \
'2'
check "add idempotent with no flags" \
"$KAPPA add cfgpkg" \
'already in packages'
# ═══════════════════════════════════════════ # ═══════════════════════════════════════════
echo "" echo ""
echo "=== Install: list and rollback ===" echo "=== Install: list and rollback ==="
@@ -670,6 +703,64 @@ check "resolve deptree (c has dep)" \
"$KAPPA resolve $TMPDIR/deptree-config.kap 2>&1" \ "$KAPPA resolve $TMPDIR/deptree-config.kap 2>&1" \
'dep-c (1 deps)' 'dep-c (1 deps)'
# Transitive dependency resolution
cat > "$KAPPA_ROOT/cache/packages/trans-a.kap" << 'TRANSEOF'
package "trans-a" {
version = "1.0"
source = "a.tar.gz"
sha256 = "abc"
license = "MIT"
build { echo a }
install { echo a }
}
TRANSEOF
cat > "$KAPPA_ROOT/cache/packages/trans-b.kap" << 'TRANSEOF'
package "trans-b" {
version = "1.0"
source = "b.tar.gz"
sha256 = "abc"
license = "MIT"
depends = [{ name = "trans-a" }]
build { echo b }
install { echo b }
}
TRANSEOF
cat > "$KAPPA_ROOT/cache/packages/trans-c.kap" << 'TRANSEOF'
package "trans-c" {
version = "1.0"
source = "c.tar.gz"
sha256 = "abc"
license = "MIT"
depends = [{ name = "trans-b" }]
build { echo c }
install { echo c }
}
TRANSEOF
cat > "$TMPDIR/transitive-config.kap" << 'TRANSEOF'
system { hostname = "test" }
packages { trans-c {} }
services {}
boot {
kernel = "linux"
init = "s6"
root = "/dev/sda1"
bootloader = "limine"
}
TRANSEOF
check "transitive deps auto-resolve (only c declared)" \
"$KAPPA resolve $TMPDIR/transitive-config.kap 2>&1" \
'trans-a (0 deps)'
check "transitive deps include intermediate" \
"$KAPPA resolve $TMPDIR/transitive-config.kap 2>&1" \
'trans-b (1 deps)'
check "transitive deps resolve root last" \
"$KAPPA resolve $TMPDIR/transitive-config.kap 2>&1" \
'trans-c (1 deps)'
# ═══════════════════════════════════════════ # ═══════════════════════════════════════════
echo "" echo ""
echo "=== Build: simple execution ===" echo "=== Build: simple execution ==="
@@ -955,6 +1046,62 @@ check "parse-config with features" \
# ═══════════════════════════════════════════ # ═══════════════════════════════════════════
echo "" echo ""
echo ""
echo "=== Search: cached index queries ==="
echo ""
mkdir -p "$KAPPA_ROOT/cache/indexes"
cat > "$KAPPA_ROOT/cache/indexes/test-repo-stable.kap" << 'SRCHEOF'
index "test-repo/stable" {
trans-a { version = "1.0" }
trans-b { version = "1.0" }
trans-c { version = "1.0" }
testpkg { version = "1.0" }
}
SRCHEOF
check "search finds package by name" \
"$KAPPA search trans-a" \
'trans-a'
check "search finds by substring" \
"$KAPPA search ans" \
'trans-a'
check "search shows repo source" \
"$KAPPA search trans-a" \
'test-repo/stable'
check "search no match" \
"$KAPPA search zzz999" \
'no packages matching'
echo ""
echo "=== Upgrade: version comparison ==="
echo ""
mkdir -p "$KAPPA_ROOT/db"
cat > "$KAPPA_ROOT/db/installed" << 'UPGEOF'
trans-a 0.9 a1b2c3d4e5f6a7b8
trans-b 0.9 b2c3d4e5f6a7b8c9
trans-c 1.0 c3d4e5f6a7b8c9d0
UPGEOF
check "upgrade detects newer versions" \
"$KAPPA upgrade 2>&1" \
'trans-a'
check "upgrade shows old version" \
"$KAPPA upgrade 2>&1" \
'0.9'
check "upgrade dry-run does not apply" \
"$KAPPA upgrade --dry-run 2>&1" \
'run kappa add'
rm -f "$KAPPA_ROOT/db/installed"
echo "=== Rebuild: dry-run detection ===" echo "=== Rebuild: dry-run detection ==="
echo "" echo ""