Skip to content

Commit 0f5c077

Browse files
author
Jerry Xie
committed
test: add regression test for cask inclusion in SelectedPkgs
Adds TestRunCustomInstall_IncludesCasksInSelectedPkgs to verify that GUI apps (casks) from remote configs are properly added to SelectedPkgs. This prevents regression of the bug where casks were silently skipped during remote config installation. Related to #17
1 parent d9360ae commit 0f5c077

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

internal/installer/installer_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,41 @@ func TestCheckDependencies_DryRunSkipsEverything(t *testing.T) {
125125
}
126126
opts := cfg.ToInstallOptions()
127127
st := cfg.ToInstallState()
128-
err := checkDependencies(opts, st)
128+
err := runCustomInstall(opts, st)
129129
assert.NoError(t, err)
130130
}
131131

132+
// TestRunCustomInstall_IncludesCasksInSelectedPkgs verifies that GUI apps (casks)
133+
// from remote config are added to SelectedPkgs so they get installed.
134+
// Regression test for: https://github.com/openbootdotdev/openboot/issues/17
135+
func TestRunCustomInstall_IncludesCasksInSelectedPkgs(t *testing.T) {
136+
tmpDir := t.TempDir()
137+
t.Setenv("HOME", tmpDir)
138+
139+
cfg := &config.Config{
140+
DryRun: true,
141+
Shell: "skip",
142+
Macos: "skip",
143+
RemoteConfig: &config.RemoteConfig{
144+
Username: "testuser",
145+
Slug: "testconfig",
146+
Packages: config.PackageEntryList{{Name: "git"}, {Name: "curl"}},
147+
Casks: config.PackageEntryList{{Name: "visual-studio-code"}, {Name: "firefox"}},
148+
},
149+
}
150+
151+
opts := cfg.ToInstallOptions()
152+
st := cfg.ToInstallState()
153+
err := runCustomInstall(opts, st)
154+
assert.NoError(t, err)
155+
156+
// Verify both packages and casks are in SelectedPkgs
157+
assert.Contains(t, st.SelectedPkgs, "git", "CLI package should be in SelectedPkgs")
158+
assert.Contains(t, st.SelectedPkgs, "curl", "CLI package should be in SelectedPkgs")
159+
assert.Contains(t, st.SelectedPkgs, "visual-studio-code", "GUI app (cask) should be in SelectedPkgs")
160+
assert.Contains(t, st.SelectedPkgs, "firefox", "GUI app (cask) should be in SelectedPkgs")
161+
}
162+
132163
func TestRunInstall_DryRunRemoteConfig(t *testing.T) {
133164
cfg := &config.Config{
134165
DryRun: true,

0 commit comments

Comments
 (0)