From 45e0ce5a99909694fceef6f63a4556b1c9db17fb Mon Sep 17 00:00:00 2001 From: Mike Cantelon Date: Thu, 31 Oct 2024 22:44:00 -0700 Subject: [PATCH] PREMIS config tests --- internal/config/config_test.go | 2 ++ internal/premis/config_test.go | 45 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 internal/premis/config_test.go diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 85d16a28..f1fdee60 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -87,5 +87,7 @@ func TestConfig(t *testing.T) { assert.Equal(t, c.Preservation.TaskQueue, temporal.A3mWorkerTaskQueue) assert.Equal(t, c.Storage.TaskQueue, temporal.GlobalTaskQueue) assert.Equal(t, c.Temporal.TaskQueue, temporal.GlobalTaskQueue) + assert.Equal(t, c.ValidatePREMIS.Enabled, false) + assert.Equal(t, c.ValidatePREMIS.XSDPath, "") }) } diff --git a/internal/premis/config_test.go b/internal/premis/config_test.go new file mode 100644 index 00000000..0eb159fb --- /dev/null +++ b/internal/premis/config_test.go @@ -0,0 +1,45 @@ +package premis_test + +import ( + "testing" + + "gotest.tools/v3/assert" + + "github.com/artefactual-sdps/enduro/internal/premis" +) + +func TestConfig(t *testing.T) { + t.Parallel() + + type test struct { + name string + config *premis.Config + wantErr string + } + for _, tt := range []test{ + { + name: "Passes validation (disabled)", + config: &premis.Config{ + Enabled: false, + }, + }, + { + name: "Fails validation (missing XmlPath)", + config: &premis.Config{ + Enabled: true, + }, + wantErr: "xsdPath is required in the [validatePremis] configuration when enabled", + }, + } { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + + err := tt.config.Validate() + if tt.wantErr != "" { + assert.Error(t, err, tt.wantErr) + return + } + assert.NilError(t, err) + }) + } +}