Skip to content

Commit

Permalink
Add check on files
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Nov 15, 2024
1 parent 41639aa commit 55a4c33
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions internal/handlers/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ func CheckMyWork(w http.ResponseWriter, r *http.Request) {
}
}

if column == "File Path" {
model := ColumnValue("Object Model", header, row)
if strInSlice(model, []string{"Binary", "Video", "Page", "Image", "Digital Document"}) {
errors[i] = "Missing source file"
}
}

continue
}

Expand Down
22 changes: 21 additions & 1 deletion internal/handlers/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestCheckMyWork(t *testing.T) {
response: `{"C2":"Missing value"}`,
},
{
name: "Missing file",
name: "Non-existent file",
method: http.MethodPost,
body: [][]string{
{"Title", "Object Model", "Full Title", "File Path"},
Expand All @@ -102,6 +102,26 @@ func TestCheckMyWork(t *testing.T) {
statusCode: http.StatusOK,
response: `{"D2":"File does not exist in islandora_staging"}`,
},
{
name: "Missing file",
method: http.MethodPost,
body: [][]string{
{"Title", "Object Model", "Full Title", "File Path"},
{"foo", "Image", "foo", ""},
},
statusCode: http.StatusOK,
response: `{"D2":"Missing source file"}`,
},
{
name: "Missing file OK",
method: http.MethodPost,
body: [][]string{
{"Title", "Object Model", "Full Title", "File Path"},
{"foo", "Paged Content", "foo", ""},
},
statusCode: http.StatusOK,
response: `{}`,
},
{
name: "Missing supplemental file",
method: http.MethodPost,
Expand Down

0 comments on commit 55a4c33

Please sign in to comment.