diff --git a/repos.go b/repos.go index f71fe57..2528492 100644 --- a/repos.go +++ b/repos.go @@ -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) != "" { diff --git a/repos_test.go b/repos_test.go index cbcd255..33a8dc7 100644 --- a/repos_test.go +++ b/repos_test.go @@ -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) +}