Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (r *Repository) APTConfigLine() string {
res += "deb "
}
if strings.TrimSpace(r.Options) != "" {
res += "[" + r.Options + "]"
res += "[" + r.Options + "] "
}
res += r.URI + " " + r.Distribution + " " + r.Components
if strings.TrimSpace(r.Comment) != "" {
Expand Down
22 changes: 22 additions & 0 deletions repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,25 @@ func TestAddAndRemoveRepository(t *testing.T) {
require.False(t, repos.Contains(repo1), "Configuration contains: %#v", repo1)
require.True(t, repos.Contains(repo2), "Configuration contains: %#v", repo2)
}

func TestAPTConfigLine(t *testing.T) {
r := &Repository{
Enabled: true,
SourceRepo: false,
Options: "signed-by=/etc/apt/keyrings/docker.asc",
URI: "https://download.docker.com/linux/debian",
Distribution: "bookworm",
Components: "stable",
Comment: "Docker's Apt repository.",
}

got := r.APTConfigLine()
expected := "deb [signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable # Docker's Apt repository."
require.True(t, got == expected)

r.Enabled = false
r.SourceRepo = true
got = r.APTConfigLine()
expected = "# deb-src [signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable # Docker's Apt repository."
require.True(t, got == expected)
}