mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-06 09:25:27 +08:00
feat: Introduce a new Go-based test suite runner with supporting scripts and documentation.
This commit is contained in:
36
cmd/ds2api-tests/main.go
Normal file
36
cmd/ds2api-tests/main.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"ds2api/internal/testsuite"
|
||||
)
|
||||
|
||||
func main() {
|
||||
opts := testsuite.DefaultOptions()
|
||||
var timeoutSeconds int
|
||||
|
||||
flag.StringVar(&opts.ConfigPath, "config", opts.ConfigPath, "Path to config file (default: config.json)")
|
||||
flag.StringVar(&opts.AdminKey, "admin-key", opts.AdminKey, "Admin key (default: DS2API_ADMIN_KEY or admin)")
|
||||
flag.StringVar(&opts.OutputDir, "out", opts.OutputDir, "Output artifact directory")
|
||||
flag.IntVar(&opts.Port, "port", opts.Port, "Server port (0 means auto-select free port)")
|
||||
flag.IntVar(&timeoutSeconds, "timeout", int(opts.Timeout.Seconds()), "Per-request timeout in seconds")
|
||||
flag.IntVar(&opts.Retries, "retries", opts.Retries, "Retry count for network/5xx requests")
|
||||
flag.BoolVar(&opts.NoPreflight, "no-preflight", opts.NoPreflight, "Skip preflight checks")
|
||||
flag.Parse()
|
||||
|
||||
if timeoutSeconds <= 0 {
|
||||
timeoutSeconds = 120
|
||||
}
|
||||
opts.Timeout = time.Duration(timeoutSeconds) * time.Second
|
||||
|
||||
if err := testsuite.Run(context.Background(), opts); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Fprintln(os.Stdout, "testsuite completed successfully")
|
||||
}
|
||||
Reference in New Issue
Block a user