A shepherd for your Appimages.
0

Configure Feed

Select the types of activity you want to include in your feed.

test/launch: fix missing app errors

Aly Raffauf (Jun 19, 2026, 1:17 PM EDT) f860d6bd e6bb5ceb

+35 -5
+35 -5
internal/appherder/launch_test.go
··· 1 1 package appherder 2 2 3 - import "testing" 3 + import ( 4 + "os" 5 + "path/filepath" 6 + "strings" 7 + "testing" 8 + "time" 9 + ) 4 10 5 - func TestLaunchMissingApp(t *testing.T) { 6 - a, _ := newTestApp(t) 7 - if err := a.Launch("missing"); err == nil { 8 - t.Fatal("Launch missing app succeeded, want error") 11 + func TestLaunchExecutesInstalledAppImage(t *testing.T) { 12 + app, home := newTestApp(t) 13 + marker := filepath.Join(home, "launched") 14 + script := "#!/bin/sh\nprintf launched > " + shellQuote(marker) + "\n" 15 + if err := os.MkdirAll(filepath.Join(home, "AppImages"), 0o755); err != nil { 16 + t.Fatal(err) 9 17 } 18 + if err := os.WriteFile(filepath.Join(home, "AppImages", "foo.appimage"), []byte(script), 0o755); err != nil { 19 + t.Fatal(err) 20 + } 21 + 22 + if err := app.Launch("foo"); err != nil { 23 + t.Fatal(err) 24 + } 25 + 26 + deadline := time.Now().Add(time.Second) 27 + for { 28 + if got, err := os.ReadFile(marker); err == nil && string(got) == "launched" { 29 + return 30 + } 31 + if time.Now().After(deadline) { 32 + t.Fatal("launched app did not write marker") 33 + } 34 + time.Sleep(10 * time.Millisecond) 35 + } 36 + } 37 + 38 + func shellQuote(value string) string { 39 + return "'" + strings.ReplaceAll(value, "'", `'\''`) + "'" 10 40 }