diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-05-14 18:26:01 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-05-14 18:26:01 -0400 |
| commit | 7ffc98c007601921db0677fc07c9779f71bb3499 (patch) | |
| tree | 84ef660183e9f89cad6ff3ac5f14a338aac86403 /cmd | |
| parent | 28a5aa8c8e7a61dbf06a2cd72ea1bfdee8e67ba6 (diff) | |
| download | lulu-7ffc98c007601921db0677fc07c9779f71bb3499.zip | |
cli: test validate-interior
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/lulu/main.go | 20 | ||||
| -rwxr-xr-x | cmd/lulu/test | 19 | ||||
| -rw-r--r-- | cmd/lulu/testchecks/vi | 3 | ||||
| -rw-r--r-- | cmd/lulu/tests/vi | 1 | ||||
| -rw-r--r-- | cmd/lulu/tests/vi_wrongsize | 2 |
5 files changed, 38 insertions, 7 deletions
diff --git a/cmd/lulu/main.go b/cmd/lulu/main.go index 6e6f146..8d3527b 100644 --- a/cmd/lulu/main.go +++ b/cmd/lulu/main.go @@ -118,7 +118,7 @@ func validateInterior(name string, clnt *lulu.Client, args []string) { basic bool url url.URL mfg lulu.PkgId - timeout time.Duration + timeout = defaultTimeout ) basicFlag := Flag{&boolValue{p: &basic}, "basic", "Basic validation without pod_package_id manufacturing options", false} @@ -151,7 +151,21 @@ func validateInterior(name string, clnt *lulu.Client, args []string) { if err != nil { lg.Fatal(err) } - fmt.Println(val) // TODO: output format? + + fmt.Println("status:", val.Status) + fmt.Println("id:", val.Id) + if len(val.ValidPkgIds) > 0 { + fmt.Printf("valid %ss: %v\n", typeName(val.ValidPkgIds[0]), val.ValidPkgIds) + } + + for _, err := range val.Errors { + lg.Printf("lulu error: %s\n", err) + } + if len(val.Errors) > 0 || + (basic && val.Status != lulu.InteriorStatusValidated) || + val.Status != lulu.InteriorStatusNormalized { + os.Exit(1) + } } func validateCover(name string, clnt *lulu.Client, args []string) { @@ -159,7 +173,7 @@ func validateCover(name string, clnt *lulu.Client, args []string) { url url.URL mfg lulu.PkgId nPages uint - timeout time.Duration + timeout = defaultTimeout ) fs := newFlagSet(name, []Flag{ Flag{&urlValue{p: &url}, "url", "URL of cover file for Lulu to download", true}, diff --git a/cmd/lulu/test b/cmd/lulu/test index e819005..375cc95 100755 --- a/cmd/lulu/test +++ b/cmd/lulu/test @@ -3,22 +3,33 @@ set -u [[ ! -d testout ]] && mkdir testout +[[ ! -d testerr ]] && mkdir testerr for test in tests/* do base=${test##*/} want=testdata/$base + check=testchecks/$base out=testout/$base - if [ -f $want ]; then - sh $test >$out 2>/dev/null + err=testerr/$base + if [ -f $want ]; then # check against expected output + sh $test >$out 2>$err if ! cmp -s $want $out then echo "FAIL $test: <Expected >Actual" diff $want $out exit 1 fi - else - if sh $test >$out 2>/dev/null + elif [ -f $check ]; then # use script to check output + sh $test >$out 2>$err + echo "checking with $check..." >>$err + if ! sh $check $out >>$err + then + echo "FAIL $test: check failed: $check" + exit 1 + fi + else # test should fail + if sh $test >$out 2>$err then echo "FAIL $test: expected error; got \"$(cat $out)\"" exit 1 diff --git a/cmd/lulu/testchecks/vi b/cmd/lulu/testchecks/vi new file mode 100644 index 0000000..5fe44a8 --- /dev/null +++ b/cmd/lulu/testchecks/vi @@ -0,0 +1,3 @@ +grep '^status: NORMALIZED$' <$1 +grep '^id: [1-9][0-9]*$' <$1 +grep '^valid PkgIds: \[[A-Z0-9. ]\+\]$' <$1 diff --git a/cmd/lulu/tests/vi b/cmd/lulu/tests/vi new file mode 100644 index 0000000..8a074c3 --- /dev/null +++ b/cmd/lulu/tests/vi @@ -0,0 +1 @@ +lulu -s vi -mfg 0600X0900.BW.PRE.PB.060UW444.MXX -url https://www.dropbox.com/sh/p3zh22vzsaegiri/AACOUn3LFKsITDzylh13bQpsa/161025/thesis2.pdf?dl=1 -t 30s diff --git a/cmd/lulu/tests/vi_wrongsize b/cmd/lulu/tests/vi_wrongsize new file mode 100644 index 0000000..b6932af --- /dev/null +++ b/cmd/lulu/tests/vi_wrongsize @@ -0,0 +1,2 @@ +# should fail with "The book size you selected does not match the page size in the file you uploaded" +lulu -s vi -mfg 0583X0827.BW.PRE.PB.060UW444.MXX -url https://www.dropbox.com/sh/p3zh22vzsaegiri/AACOUn3LFKsITDzylh13bQpsa/161025/thesis2.pdf?dl=1 |