Skip to content

Commit

Permalink
require resource type for non-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Dec 3, 2024
1 parent 81256c3 commit 30bacb7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/handlers/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 20 additions & 0 deletions internal/handlers/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 30bacb7

Please sign in to comment.