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

Function TestModuleTargetFiles

private/bufpkg/bufimage/build_image_test.go:313–362  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

311}
312
313func TestModuleTargetFiles(t *testing.T) {
314 t.Parallel()
315 moduleSet, err := bufmoduletesting.NewModuleSet(
316 bufmoduletesting.ModuleData{
317 Name: "buf.build/foo/a",
318 PathToData: map[string][]byte{
319 "a.proto": []byte(
320 `syntax = "proto3"; package a; import "b.proto";`,
321 ),
322 },
323 },
324 bufmoduletesting.ModuleData{
325 Name: "buf.build/foo/b",
326 PathToData: map[string][]byte{
327 "b.proto": []byte(
328 `syntax = "proto3"; package b; import "c.proto";`,
329 ),
330 },
331 },
332 bufmoduletesting.ModuleData{
333 Name: "buf.build/foo/c",
334 PathToData: map[string][]byte{
335 "c.proto": []byte(
336 `syntax = "proto3"; package c;`,
337 ),
338 },
339 },
340 )
341 require.NoError(t, err)
342 testTargetImageFiles := func(t *testing.T, want []string, opaqueID ...string) {
343 targetModuleSet := moduleSet
344 if len(opaqueID) > 0 {
345 var err error
346 targetModuleSet, err = moduleSet.WithTargetOpaqueIDs(opaqueID...)
347 require.NoError(t, err)
348 }
349 image, err := bufimage.BuildImage(
350 t.Context(),
351 slogtestext.NewLogger(t),
352 bufmodule.ModuleSetToModuleReadBucketWithOnlyProtoFiles(targetModuleSet),
353 )
354 require.NoError(t, err)
355 assert.Equal(t, want, testGetImageFilePaths(image))
356 }
357 testTargetImageFiles(t, []string{"a.proto", "b.proto", "c.proto"})
358 testTargetImageFiles(t, []string{"a.proto", "b.proto", "c.proto"}, "buf.build/foo/a")
359 testTargetImageFiles(t, []string{"b.proto", "c.proto"}, "buf.build/foo/b")
360 testTargetImageFiles(t, []string{"c.proto"}, "buf.build/foo/c")
361 testTargetImageFiles(t, []string{"b.proto", "c.proto"}, "buf.build/foo/b", "buf.build/foo/c")
362}
363
364func testCompare(t *testing.T, relDirPath string) {
365 dirPath := filepath.Join("testdata", relDirPath)

Callers

nothing calls this directly

Calls 6

WithTargetOpaqueIDsMethod · 0.95
NewModuleSetFunction · 0.92
BuildImageFunction · 0.92
NewLoggerFunction · 0.92
testGetImageFilePathsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…