aboutsummaryrefslogtreecommitdiffstats
path: root/cover_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'cover_test.go')
-rw-r--r--cover_test.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/cover_test.go b/cover_test.go
index a0042c1..9cbab17 100644
--- a/cover_test.go
+++ b/cover_test.go
@@ -55,3 +55,63 @@ func TestCoverDimensions(t *testing.T) {
require.NoError(t, err)
require.Equal(t, CoverDimensions{920, 666, Points}, dims)
}
+
+func TestMarshalValidateCoverReq(t *testing.T) {
+ t.Parallel()
+ want := `{
+ "source_url": "https://www.dropbox.com/sh/p3zh22vzsaegiri/AADP367j0bTWlt8fCu-_tm2ia/161025/139056_cover.pdf?dl=1",
+ "pod_package_id": "0600X0900.BW.STD.PB.060UW444.MXX",
+ "interior_page_count": 210
+ }`
+ req := validateCoverReq{
+ "https://www.dropbox.com/sh/p3zh22vzsaegiri/AADP367j0bTWlt8fCu-_tm2ia/161025/139056_cover.pdf?dl=1",
+ PkgId{
+ UsTrade,
+ Mono,
+ Standard,
+ Perfect,
+ P60UncoatedWhite,
+ Matte,
+ NoLinen,
+ NoFoil,
+ },
+ 210,
+ }
+ requireMarshalJsonEq(t, want, req)
+}
+
+func TestUnmarshalCoverValidationRecord(t *testing.T) {
+ t.Parallel()
+ data := `{
+ "id": 1,
+ "source_url": "https://www.dropbox.com/sh/p3zh22vzsaegiri/AADP367j0bTWlt8fCu-_tm2ia/161025/139056_cover.pdf?dl=1",
+ "page_count": 210,
+ "errors": null,
+ "status": "NORMALIZING"
+ }`
+ want := CoverValidationRecord{
+ 1,
+ "https://www.dropbox.com/sh/p3zh22vzsaegiri/AADP367j0bTWlt8fCu-_tm2ia/161025/139056_cover.pdf?dl=1",
+ 210,
+ "",
+ CoverStatusNormalizing,
+ }
+ requireUnmarshalJsonEq(t, want, data)
+}
+
+func TestValidateCover(t *testing.T) {
+ c := newClient(t)
+ mfg := PkgId{
+ UsTrade,
+ Mono,
+ Standard,
+ Perfect,
+ P60UncoatedWhite,
+ Gloss,
+ NoLinen,
+ NoFoil,
+ }
+ id, err := c.ValidateCover(coverUrl, mfg, 210)
+ require.NoError(t, err)
+ require.NotZero(t, id)
+}