better test + migration

This commit is contained in:
ari committed 2026-09-17 16:26:15 -04:00
1 parent 27b713affa
commit ab8260a5d0
8 files changed
+202 -34

No files matched your search

+22 -24
View File
@@ -18,11 +18,9 @@ def build-sed-expr [from: list<string>, to: list<string>] {
| str join "; ")
}
# Reproduce the tar-args assembly (everything after `tar -C $source`).
def build-tar-args [files: list<string>, dirs: list<string>] {
let file_args = $files | each {|f| ["--include" $f] } | flatten
let dir_args = $dirs | each {|d| ["--include" $"($d)/**"] } | flatten
$file_args | append $dir_args | append ["--no-recursion" "-cf" "-" "."]
# Reproduce the tar-targets assembly (positional args after `tar -cf -`).
def build-tar-targets [files: list<string>, dirs: list<string>] {
$files | append $dirs
}
# ---------------------------------------------------------------------------
@@ -42,31 +40,25 @@ def "sed expr pairs are joined with semicolons" [] {
}
@test
def "tar args: flat files produce paired --include entries" [] {
let args = build-tar-args [config.yaml .env] []
assert ("--include" in $args)
assert ("config.yaml" in $args)
assert (".env" in $args)
def "tar targets: contains all files and dirs" [] {
let targets = build-tar-targets [config.yaml auth.json .env] [connections]
assert ("config.yaml" in $targets)
assert ("auth.json" in $targets)
assert (".env" in $targets)
assert ("connections" in $targets)
}
@test
def "tar args: dirs produce glob --include entries" [] {
let args = build-tar-args [] [connections]
assert ("connections/**" in $args)
def "tar targets: no --include flags or globs" [] {
let targets = build-tar-targets [config.yaml] [connections]
assert (not ("--include" in $targets))
assert (not (($targets | any {|x| $x | str contains "**" })))
}
@test
def "tar args: always end with --no-recursion -cf - ." [] {
let args = build-tar-args [config.yaml] [connections]
let tail = $args | last 4
assert equal $tail ["--no-recursion" "-cf" "-" "."]
}
@test
def "tar args: result is a flat list of strings spreadable with spread operator" [] {
let args = build-tar-args [config.yaml auth.json] [connections]
# Every element must be a string so `...$args` works with ^tar.
let all_strings = $args | all {|x| ($x | describe) == "string" }
def "tar targets: result is a flat list of strings spreadable with spread operator" [] {
let targets = build-tar-targets [config.yaml auth.json] [connections]
let all_strings = $targets | all {|x| ($x | describe) == "string" }
assert $all_strings
}
@@ -75,3 +67,9 @@ def "migrate connections is registered in the command tree" [] {
let names = scope commands | where name =~ '^main' | get name
assert ("main migrate connections" in $names)
}
@test
def "main migrate is registered in the command tree" [] {
let names = scope commands | where name =~ '^main' | get name
assert ("main migrate" in $names)
}