Skip to content

Commit 9f91bb2

Browse files
committed
Fix apps tests: add region flag to m run and handle new org format
Two fixes for apps v2 integration tests: 1. Add -r flag to 'fly m run' commands Without specifying a region, the command prompts interactively for region selection, which fails in CI with "Error: prompt: non interactive". Fixed by adding: -r %s (f.PrimaryRegion()) Affected: - TestAppsV2ConfigSave_ProcessGroups (3 commands) - TestAppsV2ConfigSave_OneMachineNoAppConfig (1 command) 2. Handle new org list JSON format in verifyTestOrgExists The API now returns: {"personal": "flyctl-ci-preflight"} instead of: {"flyctl-ci-preflight": "..."} Updated to check both keys (old format) and values (new format) to find the org slug.
1 parent ca2bf5a commit 9f91bb2

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

test/preflight/apps_v2_integration_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ func TestAppsV2ConfigSave_ProcessGroups(t *testing.T) {
128128
appName := f.CreateRandomAppMachines()
129129
configFilePath := filepath.Join(f.WorkDir(), appconfig.DefaultConfigFileName)
130130

131-
f.Fly("m run -a %s --env ENV=preflight -- nginx nginx -g 'daemon off;'", appName)
132-
f.Fly("m run -a %s --env ENV=preflight -- nginx nginx -g 'daemon off;'", appName)
133-
f.Fly("m run -a %s --env ENV=preflight -- nginx tail -F /dev/null", appName)
131+
f.Fly("m run -a %s -r %s --env ENV=preflight -- nginx nginx -g 'daemon off;'", appName, f.PrimaryRegion())
132+
f.Fly("m run -a %s -r %s --env ENV=preflight -- nginx nginx -g 'daemon off;'", appName, f.PrimaryRegion())
133+
f.Fly("m run -a %s -r %s --env ENV=preflight -- nginx tail -F /dev/null", appName, f.PrimaryRegion())
134134
f.Fly("m list -a %s", appName)
135135
result := f.Fly("config save -a %s", appName)
136136
configFileBytes, err := os.ReadFile(configFilePath)
@@ -151,7 +151,7 @@ func TestAppsV2ConfigSave_OneMachineNoAppConfig(t *testing.T) {
151151
appName := f.CreateRandomAppMachines()
152152
configFilePath := filepath.Join(f.WorkDir(), appconfig.DefaultConfigFileName)
153153

154-
f.Fly("m run -a %s --env ENV=preflight -- nginx tail -F /dev/null", appName)
154+
f.Fly("m run -a %s -r %s --env ENV=preflight -- nginx tail -F /dev/null", appName, f.PrimaryRegion())
155155
if _, err := os.Stat(configFilePath); !errors.Is(err, os.ErrNotExist) {
156156
f.Fatalf("config file exists at %s :-(", configFilePath)
157157
}

test/preflight/testlib/test_env.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,22 @@ func (f *FlyctlTestEnv) verifyTestOrgExists() {
279279
result.AssertSuccessfulExit()
280280
var orgMap map[string]string
281281
result.StdOutJSON(&orgMap)
282-
if _, present := orgMap[f.orgSlug]; !present {
282+
283+
// Check if org exists as a key (old format) or as a value (new format)
284+
found := false
285+
if _, present := orgMap[f.orgSlug]; present {
286+
found = true
287+
} else {
288+
// Check values for org slug (handles {"personal": "flyctl-ci-preflight"} format)
289+
for _, v := range orgMap {
290+
if v == f.orgSlug {
291+
found = true
292+
break
293+
}
294+
}
295+
}
296+
297+
if !found {
283298
f.Fatalf("could not find org with name '%s' in `%s` output: %s", f.orgSlug, result.cmdStr, result.stdOut.String())
284299
}
285300
}

0 commit comments

Comments
 (0)