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

Function TestWriteUniqueFile_NeverOverwrites

cmd/root/record_tui_test.go:12–25  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestWriteUniqueFile_NeverOverwrites(t *testing.T) {
13 base := filepath.Join(t.TempDir(), "rec")
14
15 existing := base + "_test.go"
16 require.NoError(t, os.WriteFile(existing, []byte("precious"), 0o600))
17
18 path, err := writeUniqueFile(base, []byte("generated"))
19 require.NoError(t, err)
20
21 assert.Equal(t, base+"_2_test.go", path)
22 got, err := os.ReadFile(existing)
23 require.NoError(t, err)
24 assert.Equal(t, "precious", string(got), "pre-existing file must not be clobbered")
25}
26
27func TestWriteUniqueFile_WritesFirstCandidate(t *testing.T) {
28 base := filepath.Join(t.TempDir(), "rec")

Callers

nothing calls this directly

Calls 2

writeUniqueFileFunction · 0.85
ReadFileMethod · 0.80

Tested by

no test coverage detected