Files
mtusi2026lab6/internal/config/objectstore_test.go
T

25 lines
739 B
Go

package config
import "testing"
// TestObjectStoreConfiguration verifies mandatory credentials and opt-in local plaintext.
func TestObjectStoreConfiguration(t *testing.T) {
t.Run("missing credentials", func(t *testing.T) {
t.Setenv("S3_ENDPOINT", "")
if _, err := NewObjectStore(); err == nil {
t.Fatal("missing endpoint accepted")
}
})
t.Run("local configuration", func(t *testing.T) {
t.Setenv("S3_ENDPOINT", "localhost:9000")
t.Setenv("S3_BUCKET", "attachments")
t.Setenv("S3_ACCESS_KEY", "test")
t.Setenv("S3_SECRET_KEY", "synthetic-only")
t.Setenv("S3_TLS", "false")
cfg, err := NewObjectStore()
if err != nil || cfg.Secure || cfg.Bucket != "attachments" {
t.Fatalf("invalid result: %v", err)
}
})
}