MCPcopy Create free account
hub / github.com/bufbuild/buf / TestFile

Function TestFile

private/pkg/tmp/tmp_test.go:29–41  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestFile(t *testing.T) {
30 t.Parallel()
31 ctx := t.Context()
32 tmpFile, err := NewFile(ctx, strings.NewReader("foo"))
33 require.NoError(t, err)
34 assert.True(t, filepath.IsAbs(tmpFile.Path()))
35 data, err := os.ReadFile(tmpFile.Path())
36 assert.NoError(t, err)
37 assert.Equal(t, "foo", string(data))
38 assert.NoError(t, tmpFile.Close())
39 _, err = os.ReadFile(tmpFile.Path())
40 assert.Error(t, err)
41}
42
43func TestFileCancel(t *testing.T) {
44 t.Parallel()

Callers

nothing calls this directly

Calls 4

PathMethod · 0.95
NewFileFunction · 0.85
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…