diff --git a/internal/handlers/check.go b/internal/handlers/check.go index cecae43..1f52027 100644 --- a/internal/handlers/check.go +++ b/internal/handlers/check.go @@ -113,7 +113,7 @@ func CheckMyWork(w http.ResponseWriter, r *http.Request) { switch column { // make sure these columns are integers - case "Parent Collection", "PPI": + case "Parent Collection", "PPI", "Node ID": id, err := strconv.Atoi(cell) if err != nil { errors[i] = "Must be an integer" @@ -125,7 +125,13 @@ func CheckMyWork(w http.ResponseWriter, r *http.Request) { errors[i] = fmt.Sprintf("Could not identify parent collection %d", id) } } - // make sure these columns are valid URLs + if column == "Node ID" { + url := fmt.Sprintf("https://preserve.lehigh.edu/node/%d?_format=json", id) + if !checkURL(url) { + errors[i] = fmt.Sprintf("Could not find node ID %d", id) + } + } + // make sure these columns are valid URLs case "Catalog or ArchivesSpace URL": parsedURL, err := url.ParseRequestURI(cell) if err != nil || parsedURL.Scheme == "" && parsedURL.Host == "" { diff --git a/internal/handlers/check_test.go b/internal/handlers/check_test.go index 0cea8c8..de943d9 100644 --- a/internal/handlers/check_test.go +++ b/internal/handlers/check_test.go @@ -335,7 +335,7 @@ func TestCheckMyWork(t *testing.T) { method: http.MethodPost, body: [][]string{ {"Title", "Object Model", "Full Title", "Node ID"}, - {"", "", "", "foo"}, + {"", "", "", "2"}, }, statusCode: http.StatusOK, response: `{}`, diff --git a/internal/handlers/transform_test.go b/internal/handlers/transform_test.go index 6bbf87c..13c2989 100644 --- a/internal/handlers/transform_test.go +++ b/internal/handlers/transform_test.go @@ -123,7 +123,7 @@ func equalStringSlices(a, b []string) bool { return false } for i := range a { - if a[i] != b[i] { + if !strInSlice(a[i], b) { return false } }