@@ -22,15 +22,28 @@ type APITestSuite struct {
2222 RunID string
2323}
2424
25- // TestScriptsAPI runs testscript scenarios that require real API access.
26- // Run with: go test -v -tags=api -timeout 30m
25+ // TestScriptsAPICompute runs API e2e scenarios under scenarios/with-api/compute/.
26+ // Run with: go test -v -tags=api -timeout 30m -run TestScriptsAPICompute
27+ func TestScriptsAPICompute (t * testing.T ) {
28+ runAPITestSuite (t , "scenarios/with-api/compute" )
29+ }
30+
31+ // TestScriptsAPIDBaaS runs API e2e scenarios under scenarios/with-api/dbaas/.
32+ // Run with: go test -v -tags=api -timeout 30m -run TestScriptsAPIDBaaS
33+ func TestScriptsAPIDBaaS (t * testing.T ) {
34+ runAPITestSuite (t , "scenarios/with-api/dbaas" )
35+ }
36+
37+ // runAPITestSuite is the shared runner for per-suite API test functions.
38+ // dir is the directory of .txtar scenarios to run (relative to the e2e package).
2739//
2840// Required environment variables:
2941//
3042// EXOSCALE_API_KEY - Exoscale API key
3143// EXOSCALE_API_SECRET - Exoscale API secret
3244// EXOSCALE_ZONE - Zone to run tests in (default: ch-gva-2)
33- func TestScriptsAPI (t * testing.T ) {
45+ func runAPITestSuite (t * testing.T , dir string ) {
46+ t .Helper ()
3447 if os .Getenv ("EXOSCALE_API_KEY" ) == "" || os .Getenv ("EXOSCALE_API_SECRET" ) == "" {
3548 t .Skip ("Skipping API tests: EXOSCALE_API_KEY and EXOSCALE_API_SECRET must be set" )
3649 }
@@ -48,13 +61,12 @@ func TestScriptsAPI(t *testing.T) {
4861 RunID : runID ,
4962 }
5063
51- // Run all scenarios under scenarios/with-api/
52- files , err := findTestScripts ("scenarios/with-api" )
64+ files , err := findTestScripts (dir )
5365 if err != nil {
5466 t .Fatal (err )
5567 }
5668 if len (files ) == 0 {
57- t .Log ("No API test scenarios found in scenarios/with-api/" )
69+ t .Logf ("No API test scenarios found in %s/" , dir )
5870 return
5971 }
6072
0 commit comments