Skip to content

Commit

Permalink
Check for Node ID
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Dec 4, 2024
1 parent 88c3ca6 commit 1c284e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions internal/handlers/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: `{}`,
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 1c284e4

Please sign in to comment.