35d72fccbe
Feature/remove mocks * remove mocks * cleanup db migrations
60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package documentstore
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"queryorchestration/internal/serviceconfig"
|
|
"queryorchestration/internal/serviceconfig/queue/documentinit"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
type DocInitConfig struct {
|
|
serviceconfig.BaseConfig
|
|
documentinit.DocInitConfig
|
|
}
|
|
|
|
func TestNewDocumentStoreService(t *testing.T) {
|
|
svc := New(&DocInitConfig{})
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestProcess_UnsupportedEvent(t *testing.T) {
|
|
svc := New(&DocInitConfig{})
|
|
|
|
// Test unsupported event type - should return nil without error
|
|
err := svc.Process(t.Context(), Params{
|
|
Event: "ObjectRemoved:Delete",
|
|
Key: "test-key",
|
|
Bucket: "test-bucket",
|
|
})
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func TestProcess_InvalidKey(t *testing.T) {
|
|
svc := New(&DocInitConfig{})
|
|
|
|
// Test invalid key that can't be parsed - should return nil without error
|
|
err := svc.Process(t.Context(), Params{
|
|
Event: EventS3ObjectCreatedPut,
|
|
Key: "invalid-key-without-proper-structure",
|
|
Bucket: "test-bucket",
|
|
})
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func TestProcess_NonImportLocation(t *testing.T) {
|
|
svc := New(&DocInitConfig{})
|
|
|
|
// Test key with Export location - should return nil without error (unsupported key)
|
|
// Key format: {client_id}/{location}/{date}/{filename}
|
|
// Export location doesn't have a part number
|
|
err := svc.Process(t.Context(), Params{
|
|
Event: EventS3ObjectCreatedPut,
|
|
Key: "testclient/export/20240101/2024-01-01T120000Z~testclient~export~550e8400-e29b-41d4-a716-446655440000.pdf",
|
|
Bucket: "test-bucket",
|
|
})
|
|
require.NoError(t, err)
|
|
}
|