package main import ( "os" "path/filepath" "reflect" "strings" "testing" ) // feh's shape (novox/hq ADR 0208): no seat; it requires the X display on its own machine, carries // the wallpaper as its own archive (ADR 0205), owns ~/.fehbg pointing at it, and sets it once from // the session's start. func TestItRequiresTheXDisplayAndClaimsNothing(t *testing.T) { m := readManifest(t) if m.Module != "feh" || m.Seats != nil || m.Claims != nil { t.Fatalf("module %q, seats %v, claims %v", m.Module, m.Seats, m.Claims) } if !reflect.DeepEqual(m.Requires, []string{"x11-display"}) { t.Fatalf("requires: %v", m.Requires) } if present, absent := m.packages(); !reflect.DeepEqual(present, []string{"feh"}) || absent != nil { t.Fatalf("packages: %v, absent %v", present, absent) } } func TestTheWallpaperIsTheModulesOwnArchive(t *testing.T) { m := readManifest(t) a := m.resource(t, "wallpapers") if a["type"] != "archive" || a["artifact"] != "wallpapers" || a["path"] != "${machine:account-home}/.local/share/feh/wallpapers" || a["owner"] != "${machine:account}" { t.Fatalf("%v", a) } found := false for _, art := range m.Build.Artifacts { if art["name"] == "wallpapers" && art["kind"] == "archive" && art["from"] == "wallpaper" { found = true } } if !found { t.Fatal("no archive artifact built from wallpaper/") } info, err := os.Stat(filepath.Join("..", "..", "wallpaper", "default.jpg")) if err != nil || info.Size() == 0 { t.Fatalf("the image: %v", err) } } func TestFehbgIsOwnedAndTheSessionStartRunsItOnce(t *testing.T) { m := readManifest(t) m.sameAsSource(t, "fehbg", "files/fehbg") f := m.resource(t, "fehbg") if f["path"] != "${machine:account-home}/.fehbg" || f["mode"] != "0755" { t.Fatalf("%v", f) } if c := f["content"].(string); !strings.Contains(c, "$HOME/.local/share/feh/wallpapers/default.jpg") || strings.Contains(c, ".hal") { t.Fatalf("%s", c) } if len(m.Shell) != 1 || m.Shell[0].For != "xinitrc" || m.Shell[0].Slot != "normal" || strings.Count(m.Shell[0].Code, `"$HOME/.fehbg"`) != 1 { t.Fatalf("%+v", m.Shell) } } func TestTheKeyThatRestoresTheWallpaperIsAnI3DropIn(t *testing.T) { m := readManifest(t) m.i3LinesAreSource(t, "files/i3/50-feh.conf") if p := m.i3Lines(); p == "" { t.Fatalf("path: %v", p) } if c := m.i3Lines(); !strings.Contains(c, "bindsym $mod+Shift+b exec --no-startup-id ~/.fehbg\n") { t.Fatalf("%s", c) } } func TestTheToolsAgreeWithTheManifest(t *testing.T) { m := readManifest(t) checkTheToolsAgree(t, m) checkNoSecretsOrInstallationNames(t) }