xtablo-source/backend/internal/files/store_test.go
Arthur Belleville 3327a4286d
test(05-01): add RED test scaffold for FILE-01..06 and MinIO in compose.yaml
- Create handlers_files_test.go: six TestFile* stubs (all t.Skip), stubbedFileStorer no-op implementing files.FileStorer
- Create store_test.go: compile-time interface assertion, TestNewStore_SkipIfNoEndpoint skips when S3_ENDPOINT unset
- Update compose.yaml: add minio (port 9000/9001) and minio-init services; minio-init uses restart: no (Pitfall 7); add minio_data volume
2026-05-15 12:19:23 +02:00

51 lines
1.3 KiB
Go

package files
import (
"context"
"os"
"testing"
)
// TestStoreImplementsFileStorer is a compile-time assertion that *Store
// satisfies the FileStorer interface.
func TestStoreImplementsFileStorer(t *testing.T) {
var _ FileStorer = (*Store)(nil)
}
// TestNewStore_SkipIfNoEndpoint verifies that NewStore returns a non-nil client
// when S3_ENDPOINT is configured. The test is skipped in CI / local dev unless
// a real MinIO instance is running and S3_ENDPOINT is set.
func TestNewStore_SkipIfNoEndpoint(t *testing.T) {
endpoint := os.Getenv("S3_ENDPOINT")
if endpoint == "" {
t.Skip("S3_ENDPOINT not set — skipping live NewStore test")
}
bucket := os.Getenv("S3_BUCKET")
if bucket == "" {
bucket = "xtablo-dev"
}
region := os.Getenv("S3_REGION")
if region == "" {
region = "us-east-1"
}
accessKey := os.Getenv("S3_ACCESS_KEY")
if accessKey == "" {
accessKey = "minioadmin"
}
secretKey := os.Getenv("S3_SECRET_KEY")
if secretKey == "" {
secretKey = "minioadmin"
}
store, err := NewStore(context.Background(), endpoint, bucket, region, accessKey, secretKey, true)
if err != nil {
t.Fatalf("NewStore: %v", err)
}
if store == nil {
t.Fatal("NewStore returned nil store without error")
}
if store.client == nil {
t.Fatal("NewStore returned store with nil S3 client")
}
}