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

Function testBuildLsFilesFormatImport

cmd/buf/buf_test.go:4585–4598  ·  view source on GitHub ↗

testBuildLsFilesFormatImport does effectively an ls-files, but via doing a build of an Image, and then listing the files from the image as if --format=import was set.

(t *testing.T, expectedExitCode int, expectedFiles []string, buildArgs ...string)

Source from the content-addressed store, hash-verified

4583// testBuildLsFilesFormatImport does effectively an ls-files, but via doing a build of an Image, and then
4584// listing the files from the image as if --format=import was set.
4585func testBuildLsFilesFormatImport(t *testing.T, expectedExitCode int, expectedFiles []string, buildArgs ...string) {
4586 buffer := bytes.NewBuffer(nil)
4587 testRun(t, expectedExitCode, nil, buffer, append([]string{"build", "-o", "-"}, buildArgs...)...)
4588 protoImage := &imagev1.Image{}
4589 err := protoencoding.NewWireUnmarshaler(nil).Unmarshal(buffer.Bytes(), protoImage)
4590 require.NoError(t, err)
4591 image, err := bufimage.NewImageForProto(protoImage)
4592 require.NoError(t, err)
4593 var paths []string
4594 for _, imageFile := range image.Files() {
4595 paths = append(paths, imageFile.Path())
4596 }
4597 require.Equal(t, expectedFiles, paths)
4598}
4599
4600func testModInit(t *testing.T, expectedData string, document bool, name string, deps ...string) {
4601 tempDir := t.TempDir()

Callers 1

Calls 7

NewWireUnmarshalerFunction · 0.92
NewImageForProtoFunction · 0.92
testRunFunction · 0.85
UnmarshalMethod · 0.65
BytesMethod · 0.65
FilesMethod · 0.65
PathMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…