correctly remove duplicated secrets and ssh keys

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-02-28 15:23:46 +01:00
parent 4ed1e07f16
commit fe17ebda89
4 changed files with 56 additions and 2 deletions

View File

@ -82,4 +82,17 @@ func TestSSHKeys(t *testing.T) {
result := actual.Equals(expected)
require.True(t, result.True())
})
t.Run("RemoveDupes", func(t *testing.T) {
sshkeys := SSHKeys{
{ID: "default"},
{ID: "key", Paths: []string{"path/to/foo"}},
{ID: "key", Paths: []string{"path/to/bar"}},
}.Normalize()
expected := `[{"id":"default"},{"id":"key","paths":["path/to/bar"]}]`
actual, err := json.Marshal(sshkeys)
require.NoError(t, err)
require.JSONEq(t, expected, string(actual))
})
}