A shepherd for your Appimages.
0

Configure Feed

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

test/icons: fix regression tests

Aly Raffauf (Jun 19, 2026, 1:17 PM EDT) 051a57ad 92e46aa5

+75
+75
internal/appherder/icons_test.go
··· 1 1 package appherder 2 2 3 3 import ( 4 + "bytes" 4 5 "os" 6 + "os/exec" 5 7 "path/filepath" 6 8 "testing" 7 9 "testing/fstest" ··· 124 126 t.Fatalf("expected stale icon to be removed, stat err: %v", err) 125 127 } 126 128 } 129 + 130 + func TestInstallAppImageWritesExtensionedDirIconPath(t *testing.T) { 131 + if _, err := exec.LookPath("mksquashfs"); err != nil { 132 + t.Skip("mksquashfs not installed") 133 + } 134 + 135 + app, home := newTestApp(t) 136 + appimage := makeAppImageFixture(t, map[string][]byte{ 137 + ".DirIcon": []byte("\x89PNG\r\n\x1a\npng"), 138 + "keepassxc.desktop": []byte( 139 + "[Desktop Entry]\n" + 140 + "Type=Application\n" + 141 + "Name=KeePassXC\n" + 142 + "Exec=keepassxc %U\n", 143 + ), 144 + }) 145 + 146 + name, err := app.Install(appimage) 147 + if err != nil { 148 + t.Fatal(err) 149 + } 150 + if name != "keepassxc" { 151 + t.Fatalf("installed name = %q, want keepassxc", name) 152 + } 153 + 154 + iconPath := filepath.Join(home, "AppImages", ".icons", "keepassxc.png") 155 + if _, err := os.Stat(iconPath); err != nil { 156 + t.Fatalf("installed icon missing: %v", err) 157 + } 158 + desktop, err := os.ReadFile(filepath.Join(home, ".local", "share", "applications", "keepassxc.desktop")) 159 + if err != nil { 160 + t.Fatal(err) 161 + } 162 + want := "Icon=" + iconPath + "\n" 163 + if !bytes.Contains(desktop, []byte(want)) { 164 + t.Fatalf("desktop file missing %q:\n%s", want, desktop) 165 + } 166 + } 167 + 168 + func makeAppImageFixture(t *testing.T, files map[string][]byte) string { 169 + t.Helper() 170 + 171 + root := filepath.Join(t.TempDir(), "root") 172 + if err := os.MkdirAll(root, 0o755); err != nil { 173 + t.Fatal(err) 174 + } 175 + for name, content := range files { 176 + path := filepath.Join(root, name) 177 + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { 178 + t.Fatal(err) 179 + } 180 + if err := os.WriteFile(path, content, 0o644); err != nil { 181 + t.Fatal(err) 182 + } 183 + } 184 + 185 + squashfs := filepath.Join(t.TempDir(), "payload.squashfs") 186 + cmd := exec.Command("mksquashfs", root, squashfs, "-noappend", "-quiet") 187 + if out, err := cmd.CombinedOutput(); err != nil { 188 + t.Fatalf("mksquashfs: %v\n%s", err, out) 189 + } 190 + payload, err := os.ReadFile(squashfs) 191 + if err != nil { 192 + t.Fatal(err) 193 + } 194 + 195 + layout := buildSignableELF(0, 0) 196 + appimage := filepath.Join(t.TempDir(), "fixture.AppImage") 197 + if err := os.WriteFile(appimage, append(layout.bytes, payload...), 0o755); err != nil { 198 + t.Fatal(err) 199 + } 200 + return appimage 201 + }