From 2760e51d53de185ca9bd7b8a1bb8296b00a428f1 Mon Sep 17 00:00:00 2001 From: Mike Cantelon Date: Fri, 8 Nov 2024 02:31:35 -0800 Subject: [PATCH] Test for non-existent XSD --- internal/premis/config_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/premis/config_test.go b/internal/premis/config_test.go index 8839ff95..d91607ce 100644 --- a/internal/premis/config_test.go +++ b/internal/premis/config_test.go @@ -1,6 +1,7 @@ package premis_test import ( + "fmt" "testing" "gotest.tools/v3/assert" @@ -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)", @@ -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)",