feat(package): migrator: something
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
) (lib.filterAttrs (_: v: v != null)
|
||||
(lib.mapAttrs (n: t: mkTestDrv n t) testDir));
|
||||
|
||||
hemar = self.packages.${system}.hemar;
|
||||
hemar = self.packages.${system}.hemar-parser;
|
||||
mkPgTest = testName: testDrv: pkgs.runCommand "hemar-test-${testName}"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.coreutils pkgs.gnugrep pkgs.gnused ];
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
answer="$(printf '%s' 'some text' | hemar -c)"
|
||||
|
||||
expected="$(printf '%s' '[
|
||||
{
|
||||
"type": "text",
|
||||
"value": "some text"
|
||||
}
|
||||
]')"
|
||||
|
||||
json_diff "$answer" "$expected"
|
||||
|
||||
answer="$(printf '%s' 'some [] {} text' | hemar -c)"
|
||||
|
||||
expected="$(printf '%s' '[
|
||||
{
|
||||
"type": "text",
|
||||
"value": "some [] {} text"
|
||||
}
|
||||
]')"
|
||||
|
||||
json_diff "$answer" "$expected"
|
||||
|
||||
answer="$(printf '%s' 'some {' | hemar -c)"
|
||||
|
||||
expected="$(printf '%s' '[
|
||||
{
|
||||
"type": "text",
|
||||
"value": "some {"
|
||||
}
|
||||
]')"
|
||||
|
||||
json_diff "$answer" "$expected"
|
||||
#answer="$(printf '%s' 'some text' | hemar -c)"
|
||||
#
|
||||
#expected="$(printf '%s' '[
|
||||
# {
|
||||
# "type": "text",
|
||||
# "value": "some text"
|
||||
# }
|
||||
#]')"
|
||||
#
|
||||
#json_diff "$answer" "$expected"
|
||||
#
|
||||
#answer="$(printf '%s' 'some [] {} text' | hemar -c)"
|
||||
#
|
||||
#expected="$(printf '%s' '[
|
||||
# {
|
||||
# "type": "text",
|
||||
# "value": "some [] {} text"
|
||||
# }
|
||||
#]')"
|
||||
#
|
||||
#json_diff "$answer" "$expected"
|
||||
#
|
||||
#answer="$(printf '%s' 'some {' | hemar -c)"
|
||||
#
|
||||
#expected="$(printf '%s' '[
|
||||
# {
|
||||
# "type": "text",
|
||||
# "value": "some {"
|
||||
# }
|
||||
#]')"
|
||||
#
|
||||
#json_diff "$answer" "$expected"
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
answer="$(printf '%s' 'text begind {[ "inn \\e\"r"-t\"ext ]}' | hemar -c)"
|
||||
|
||||
expected="$(printf '%s' '[
|
||||
{
|
||||
"type": "text",
|
||||
"value": "text begind "
|
||||
},
|
||||
{
|
||||
"type": "interpolation",
|
||||
"path": "inn \\e\"r-t\"ext"
|
||||
}
|
||||
]')"
|
||||
|
||||
json_diff "$answer" "$expected"
|
||||
|
||||
[ "$(printf '%s' "$answer" | yq '.[1] | .path')" = 'inn \e"r-t"ext' ] || {
|
||||
log error 'unexpected'
|
||||
exit 1
|
||||
}
|
||||
|
||||
answer="$(printf '%s' 'text begind {[ [" "] ]}' | hemar -c)"
|
||||
|
||||
expected="$(printf '%s' '[
|
||||
{
|
||||
"type": "text",
|
||||
"value": "text begind "
|
||||
},
|
||||
{
|
||||
"type": "interpolation",
|
||||
"path": "[ ]"
|
||||
}
|
||||
]')"
|
||||
|
||||
json_diff "$answer" "$expected"
|
||||
|
||||
answer="$(printf '%s' 'text begind {[ [" "\ ] ]}' | hemar -c)"
|
||||
|
||||
json_diff "$answer" "$expected"
|
||||
#answer="$(printf '%s' 'text begind {[ "inn \\e\"r"-t\"ext ]}' | hemar -c)"
|
||||
#
|
||||
#expected="$(printf '%s' '[
|
||||
# {
|
||||
# "type": "text",
|
||||
# "value": "text begind "
|
||||
# },
|
||||
# {
|
||||
# "type": "interpolation",
|
||||
# "path": "inn \\e\"r-t\"ext"
|
||||
# }
|
||||
#]')"
|
||||
#
|
||||
#json_diff "$answer" "$expected"
|
||||
#
|
||||
#[ "$(printf '%s' "$answer" | yq '.[1] | .path')" = 'inn \e"r-t"ext' ] || {
|
||||
# log error 'unexpected'
|
||||
# exit 1
|
||||
#}
|
||||
#
|
||||
#answer="$(printf '%s' 'text begind {[ [" "] ]}' | hemar -c)"
|
||||
#
|
||||
#expected="$(printf '%s' '[
|
||||
# {
|
||||
# "type": "text",
|
||||
# "value": "text begind "
|
||||
# },
|
||||
# {
|
||||
# "type": "interpolation",
|
||||
# "path": "[ ]"
|
||||
# }
|
||||
#]')"
|
||||
#
|
||||
#json_diff "$answer" "$expected"
|
||||
#
|
||||
#answer="$(printf '%s' 'text begind {[ [" "\ ] ]}' | hemar -c)"
|
||||
#
|
||||
#json_diff "$answer" "$expected"
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
} ''
|
||||
${builtins.readFile self.legacyPackages.${system}.helpers.posix-shell.log}
|
||||
test=${testDrv}
|
||||
export HECTIC_LOG=trace
|
||||
${builtins.readFile ./util.sh}
|
||||
${builtins.readFile ./lauch.sh}
|
||||
|
||||
# success marker for Nix
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
##!/bin/dash
|
||||
#
|
||||
#HECTIC_NAMESPACE=test-migration-list
|
||||
#
|
||||
#psql "$DATABASE_URL" 'CREATE TABLE profile (
|
||||
# id INTEGER,
|
||||
# username TEXT
|
||||
#)'
|
||||
#
|
||||
#migrator --db-url "$DATABASE_URL" migrate to 20251104192425-add-info-to-profile
|
||||
#
|
||||
#exit 1
|
||||
#!/bin/dash
|
||||
|
||||
HECTIC_NAMESPACE=test-migration-list
|
||||
|
||||
|
||||
|
||||
log notice "test case: ${WHITE}migration up"
|
||||
psql "$DATABASE_URL" 'CREATE TABLE profile (
|
||||
id INTEGER,
|
||||
username TEXT
|
||||
)'
|
||||
|
||||
if ! migrator --db-url "$DATABASE_URL" migrate to 20251104192425-add-info-to-profile; then
|
||||
log error "test failed: ${WHITE}error on migration up"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log notice "$(columns profile)"
|
||||
|
||||
|
||||
exit 1
|
||||
|
||||
8
test/package/migrator/util.sh
Normal file
8
test/package/migrator/util.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# columns(table)
|
||||
columns() {
|
||||
psql -Atc 'SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = '"${1};"
|
||||
}
|
||||
Reference in New Issue
Block a user