Skip to content

Commit

Permalink
PREMIS config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcantelon committed Nov 1, 2024
1 parent b40d805 commit 45e0ce5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
})
}
45 changes: 45 additions & 0 deletions internal/premis/config_test.go
Original file line number Diff line number Diff line change
@@ -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)
})
}
}

0 comments on commit 45e0ce5

Please sign in to comment.