From 7ffc98c007601921db0677fc07c9779f71bb3499 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Thu, 14 May 2026 18:26:01 -0400 Subject: cli: test validate-interior --- interior_test.go | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'interior_test.go') 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) { -- cgit v1.2.3