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 /interior_test.go | |
| parent | 28a5aa8c8e7a61dbf06a2cd72ea1bfdee8e67ba6 (diff) | |
| download | lulu-7ffc98c007601921db0677fc07c9779f71bb3499.zip | |
cli: test validate-interior
Diffstat (limited to 'interior_test.go')
| -rw-r--r-- | interior_test.go | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/interior_test.go b/interior_test.go index 110afb2..804e487 100644 --- a/interior_test.go +++ b/interior_test.go @@ -3,16 +3,16 @@ package lulu import ( "context" "testing" + _ "embed" "github.com/stretchr/testify/require" ) +//go:embed testdata/interiorvalidationreq.json +var interiorValidationReqJson string + func TestMarshalValidateInteriorReq(t *testing.T) { t.Parallel() - want := `{ - "source_url": "https://example.com/interior.pdf", - "pod_package_id": "0850X1100.BW.STD.LW.060UW444.MNG" -}` req := validateInteriorReq{ "https://example.com/interior.pdf", PkgId{ @@ -25,7 +25,7 @@ func TestMarshalValidateInteriorReq(t *testing.T) { NavyLinen, GoldFoil}, } - requireMarshalJsonEq(t, want, req) + requireMarshalJsonEq(t, interiorValidationReqJson, req) } func TestMarshalValidateInteriorBasicReq(t *testing.T) { @@ -35,25 +35,20 @@ func TestMarshalValidateInteriorBasicReq(t *testing.T) { validateInteriorBasicReq{"https://example.com/interior.pdf"}) } +//go:embed testdata/interiorvalidationresp.json +var interiorValidationRespJson string + func TestUnmarshalInteriorValidation(t *testing.T) { t.Parallel() - data := `{ - "id": 1, - "source_url": "https://www.dropbox.com/sh/p3zh22vzsaegiri/AACOUn3LFKsITDzylh13bQpsa/161025/thesis2.pdf?dl=1", - "page_count": 210, - "errors": null, - "status": "VALIDATING", - "valid_pod_package_ids": null -}` - want := InteriorValidation{ - 1, - "https://www.dropbox.com/sh/p3zh22vzsaegiri/AACOUn3LFKsITDzylh13bQpsa/161025/thesis2.pdf?dl=1", - 210, - "", - InteriorStatusValidating, - nil, + val := InteriorValidation{ + Id: 1, + SrcUrl: "https://www.dropbox.com/sh/p3zh22vzsaegiri/AACOUn3LFKsITDzylh13bQpsa/161025/thesis2.pdf?dl=1", + NPages: 210, + Errors: []string{"Book Size: The book size you selected does not match the page size in the file you uploaded."}, + Status: InteriorStatusValidating, + ValidPkgIds: nil, } - requireUnmarshalJsonEq(t, want, data) + requireUnmarshalJsonEq(t, val, interiorValidationRespJson) } func TestStartInteriorValidation(t *testing.T) { |