MCPcopy Create free account
hub / github.com/docker/docker-agent / TestUniqueNames

Function TestUniqueNames

pkg/runtime/agent_tools_test.go:13–27  ·  view source on GitHub ↗

TestUniqueNames verifies the helper backing AgentConfigInfo: it drops empty names and de-duplicates, preserving first-seen order by default (so declaration/priority order survives) and sorting case-insensitively when requested, keeping the agent-details config lines stable and readable.

(t *testing.T)

Source from the content-addressed store, hash-verified

11// declaration/priority order survives) and sorting case-insensitively when
12// requested, keeping the agent-details config lines stable and readable.
13func TestUniqueNames(t *testing.T) {
14 t.Parallel()
15
16 // Default: first-seen order preserved, empties dropped, duplicates removed.
17 got := uniqueNames([]string{"shell", "", "filesystem", "shell", "git"}, false)
18 assert.Equal(t, []string{"shell", "filesystem", "git"}, got)
19
20 // Sorted: case-insensitive ordering after de-duping. A lowercase name sorts
21 // before an uppercase one alphabetically, unlike a raw byte comparison.
22 sorted := uniqueNames([]string{"Zebra", "apple", "apple"}, true)
23 assert.Equal(t, []string{"apple", "Zebra"}, sorted)
24
25 assert.Empty(t, uniqueNames(nil, false))
26 assert.Empty(t, uniqueNames([]string{"", ""}, true))
27}

Callers

nothing calls this directly

Calls 1

uniqueNamesFunction · 0.85

Tested by

no test coverage detected