42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
|
|
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
|
)
|
|
|
|
func TestNewCommandObjectStoreFactoryErrorIsContextual(t *testing.T) {
|
|
cfg := commandObjectStoreTestConfig()
|
|
deps := commandDependencies{newObjectStore: func(context.Context, *config.Config) (storage.ObjectStore, error) {
|
|
return nil, errors.New("factory boom")
|
|
}}
|
|
|
|
_, err := newCommandObjectStoreWithDependencies(context.Background(), cfg, nil, deps)
|
|
if err == nil {
|
|
t.Fatal("expected error, got nil")
|
|
}
|
|
if !strings.Contains(err.Error(), "initialize object store backend") || !strings.Contains(err.Error(), "factory boom") {
|
|
t.Fatalf("error = %q, want factory context", err.Error())
|
|
}
|
|
}
|
|
|
|
func commandObjectStoreTestConfig() *config.Config {
|
|
return &config.Config{
|
|
Pipeline: &config.PipelineConfig{
|
|
Storage: config.StorageConfig{
|
|
Backend: "s3",
|
|
S3: &config.StorageS3Config{
|
|
Bucket: "test-bucket",
|
|
AccessKeyIDEnv: "NARRATIO_TEST_COMMAND_STORE_KEY_ID",
|
|
SecretKeyEnv: "NARRATIO_TEST_COMMAND_STORE_SECRET",
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|