diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-05-21 18:13:15 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-05-21 18:21:54 -0400 |
| commit | 06ba9b3e492ca47f6f966bd7bd6044809b989c30 (patch) | |
| tree | 8077af89b899ca57be8d688380c36bbc70534103 | |
| parent | 9d5cc798f82ff4a899984fa73014bd604d44ee32 (diff) | |
| download | lulu-06ba9b3e492ca47f6f966bd7bd6044809b989c30.zip | |
tidyv0.1.0
| -rwxr-xr-x | cmd/lulu/test | 17 | ||||
| -rw-r--r-- | cost.go | 4 | ||||
| -rw-r--r-- | lulu.go | 24 |
3 files changed, 24 insertions, 21 deletions
diff --git a/cmd/lulu/test b/cmd/lulu/test index 3aacc99..3a98d91 100755 --- a/cmd/lulu/test +++ b/cmd/lulu/test @@ -10,21 +10,20 @@ export money='[0-9]+(\.[0-9]+)? [A-Z]{3}' export pkgid='[0-9]{4}X[0-9]{4}\.[A-Z]{2}\.[A-Z]{3}\.[A-Z]{2}\.[A-Z0-9]{5,8}\.[A-Z]{3}' export time='[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z' - - -[[ ! -d testout ]] && mkdir testout -[[ ! -d testerr ]] && mkdir testerr +[[ -d testout ]] || mkdir testout +[[ -d testerr ]] || mkdir testerr [[ $# -gt 0 ]] && tests="tests/$1" || tests=tests/* for test in $tests do - echo $test... + echo $test base=${test##*/} want=testdata/$base check=testchecks/$base out=testout/$base err=testerr/$base - if [ -f $want ]; then # check against expected output + if [ -f $want ] + then # check against expected output if ! sh ${flags} $test >$out 2>$err then echo "FAIL $test: error: $err" @@ -36,7 +35,8 @@ do diff $want $out exit 1 fi - elif [ -f $check ]; then # use script to check output + elif [ -f $check ] + then # use script to check output if ! sh ${flags} $test >$out 2>$err then echo "FAIL $test: error: $err" @@ -48,7 +48,8 @@ do echo "FAIL $test: check failed: $check" exit 1 fi - elif [ -f $test ]; then # test should fail + elif [ -f $test ] + then # test should fail if sh ${flags} $test >$out 2>$err then echo "FAIL $test: expected error; got \"$(cat $out)\"" @@ -60,7 +60,9 @@ type printJobCostReq struct { ShipOpt ShippingLevel `json:"shipping_option"` } -// TODO: just use ShippingAddress? +// printJobCostReqShipAddr is a subset of a shipping address. It is +// necessary because the API returns an error if the address in a +// /print-job-cost-calculations/ request has any extra fields. type printJobCostReqShipAddr struct { City string `json:"city"` Country string `json:"country_code"` @@ -135,9 +135,9 @@ func (c *Client) StartInteriorValidationBasic(srcUrl string) (uint, error) { } func (c *Client) startInteriorValidation(payload any) (uint, error) { - var rec InteriorValidation - err := c.postDecode(validateInteriorPath, payload, http.StatusCreated, &rec) - return rec.Id, err + var val InteriorValidation + err := c.postDecode(validateInteriorPath, payload, http.StatusCreated, &val) + return val.Id, err } // GetInteriorValidation retrieves information about an interior file @@ -149,11 +149,11 @@ func (c *Client) GetInteriorValidation(id uint) (InteriorValidation, error) { if err != nil { return InteriorValidation{}, pkgErr(err) } - var rec InteriorValidation - if err := c.getDecode(path, &rec); err != nil { + var val InteriorValidation + if err := c.getDecode(path, &val); err != nil { return InteriorValidation{}, pkgErr(err) } - return rec, nil + return val, nil } // CoverDimensions calculates the required dimensions of the cover for a @@ -193,12 +193,12 @@ func (c *Client) ValidateCover(ctx context.Context, srcUrl string, mfg PkgId, np // https://api.lulu.com/docs/#tag/Files-validation/operation/Validate-Cover_create func (c *Client) StartCoverValidation(srcUrl string, mfg PkgId, npages uint) (uint, error) { payload := validateCoverReq{srcUrl, mfg, npages} - var rec CoverValidation - err := c.postDecode(validateCoverPath, payload, http.StatusCreated, &rec) + var val CoverValidation + err := c.postDecode(validateCoverPath, payload, http.StatusCreated, &val) if err != nil { return 0, pkgErr(err) } - return rec.Id, nil + return val.Id, nil } // GetCoverValidiation retrieves information about a cover file @@ -210,11 +210,11 @@ func (c *Client) GetCoverValidation(id uint) (CoverValidation, error) { if err != nil { return CoverValidation{}, pkgErr(err) } - var rec CoverValidation - if err := c.getDecode(path, &rec); err != nil { + var val CoverValidation + if err := c.getDecode(path, &val); err != nil { return CoverValidation{}, pkgErr(err) } - return rec, nil + return val, nil } // Cost calculates the cost of a hypothetical print order without |