Skip to content

Commit

Permalink
Test for non-existent XSD
Browse files Browse the repository at this point in the history
  • Loading branch information
mcantelon committed Nov 8, 2024
1 parent 8f245d3 commit 2760e51
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/premis/config_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package premis_test

import (
"fmt"
"testing"

"gotest.tools/v3/assert"
Expand All @@ -17,6 +18,12 @@ func TestConfig(t *testing.T) {
config *premis.Config
wantErr string
}

// Non-existent XSD path.
badXSDfs := fs.NewDir(t, "", fs.WithFile("missing.xsd", ""))
badXSDPath := badXSDfs.Join("missing.xsd")
badXSDfs.Remove()

for _, tt := range []test{
{
name: "Passes validation (disabled)",
Expand All @@ -35,9 +42,9 @@ func TestConfig(t *testing.T) {
name: "Fails validation (missing XSD file)",
config: &premis.Config{
Enabled: true,
XSDPath: "/fake/path/to.xsd",
XSDPath: badXSDPath,
},
wantErr: "xsdPath in [validatePremis] not found: stat /fake/path/to.xsd: no such file or directory",
wantErr: fmt.Sprintf("xsdPath in [validatePremis] not found: stat %s: no such file or directory", badXSDPath),
},
{
name: "Passes validation (enabled)",
Expand Down

0 comments on commit 2760e51

Please sign in to comment.