Files
seaweedfs/test/s3/versioning/test_main.go
T
Chris Lu b8121e0fe4 refactor: modernize S3 integration tests to use weed mini
- Added testutil/server.go with shared server lifecycle management
- Created testutil/server_test.go for server management tests
- Added versioning/s3_test_main.go with automatic TestMain implementation
- Simplified versioning/Makefile to use weed mini for test automation
- Tests now auto-manage weed mini server via TestMain
- Support for USE_EXTERNAL_SERVER=true to run against existing server
- Significant reduction in test infrastructure complexity
- All tests passing with weed mini
2025-12-24 19:20:17 -08:00

46 lines
1.0 KiB
Go

package s3api
import (
"os"
"testing"
"github.com/seaweedfs/seaweedfs/test/s3/testutil"
)
var testServer *testutil.TestServer
// TestMain sets up and tears down the test environment using weed mini
func TestMain(m *testing.M) {
var exitCode int
// Check if we should manage the server or use an existing one
if os.Getenv("USE_EXTERNAL_SERVER") != "true" {
// Start server using weed mini
config := testutil.DefaultServerConfig(nil)
config.AccessKey = "some_access_key1"
config.SecretKey = "some_secret_key1"
var err error
testServer, err = testutil.StartServer(&testMainHelper{}, config)
if err != nil {
panic("Failed to start test server: " + err.Error())
}
defer testServer.Stop()
}
// Run tests
exitCode = m.Run()
os.Exit(exitCode)
}
// testMainHelper implements the interface expected by StartServer
type testMainHelper struct{}
func (h *testMainHelper) Fatalf(format string, args ...interface{}) {
panic(format)
}
func (h *testMainHelper) Logf(format string, args ...interface{}) {
// Silent logging in TestMain
}