From 30bacb7387463971be076fc8642deaedbf26b116 Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Tue, 3 Dec 2024 14:42:04 -0500 Subject: [PATCH] require resource type for non-pages --- internal/handlers/check.go | 6 ++++++ internal/handlers/check_test.go | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/internal/handlers/check.go b/internal/handlers/check.go index 77e29ac..e7af925 100644 --- a/internal/handlers/check.go +++ b/internal/handlers/check.go @@ -94,6 +94,12 @@ func CheckMyWork(w http.ResponseWriter, r *http.Request) { errors[i] = "Missing source file" } } + if column == "Resource Type" { + model := ColumnValue("Object Model", header, row) + if model != "Page" { + errors[i] = "Must have a resource type" + } + } continue } diff --git a/internal/handlers/check_test.go b/internal/handlers/check_test.go index ae4de8d..c65c294 100644 --- a/internal/handlers/check_test.go +++ b/internal/handlers/check_test.go @@ -95,6 +95,26 @@ func TestCheckMyWork(t *testing.T) { statusCode: http.StatusOK, response: `{"A2":"Missing value"}`, }, + { + name: "Missing resource type", + method: http.MethodPost, + body: [][]string{ + {"Title", "Object Model", "Full Title", "Resource Type"}, + {"foo", "bar", "foo", ""}, + }, + statusCode: http.StatusOK, + response: `{"D2":"Must have a resource type"}`, + }, + { + name: "Missing resource type OK", + method: http.MethodPost, + body: [][]string{ + {"Title", "Object Model", "Full Title", "Resource Type"}, + {"foo", "Page", "foo", ""}, + }, + statusCode: http.StatusOK, + response: `{}`, + }, { name: "Missing model", method: http.MethodPost,