MCPcopy Index your code
hub / github.com/docker/docker-agent / TestAddAttachedFile

Function TestAddAttachedFile

pkg/session/session_options_test.go:75–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestAddAttachedFile(t *testing.T) {
76 t.Parallel()
77 t.Run("deduplicates and preserves order", func(t *testing.T) {
78 t.Parallel()
79 s := New()
80 s.AddAttachedFile("/abs/foo.go")
81 s.AddAttachedFile("/abs/bar.go")
82 s.AddAttachedFile("/abs/foo.go") // duplicate
83 assert.Equal(t, []string{"/abs/foo.go", "/abs/bar.go"}, s.AttachedFilesSnapshot())
84 })
85
86 t.Run("ignores empty paths", func(t *testing.T) {
87 t.Parallel()
88 s := New()
89 s.AddAttachedFile("")
90 assert.Empty(t, s.AttachedFilesSnapshot())
91 })
92
93 t.Run("ignores non-absolute paths", func(t *testing.T) {
94 t.Parallel()
95 s := New()
96 s.AddAttachedFile("foo.go")
97 s.AddAttachedFile("./bar.go")
98 s.AddAttachedFile("../baz.go")
99 assert.Empty(t, s.AttachedFilesSnapshot())
100 })
101
102 t.Run("snapshot is independent of session storage", func(t *testing.T) {
103 t.Parallel()
104 s := New()
105 s.AddAttachedFile("/abs/foo.go")
106 snap := s.AttachedFilesSnapshot()
107 snap[0] = "mutated"
108 assert.Equal(t, []string{"/abs/foo.go"}, s.AttachedFilesSnapshot())
109 })
110}
111
112func TestWithAttachedFiles(t *testing.T) {
113 t.Parallel()

Callers

nothing calls this directly

Calls 4

AddAttachedFileMethod · 0.80
AttachedFilesSnapshotMethod · 0.80
NewFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected