MCPcopy Index your code
hub / github.com/bufbuild/buf / TestProtoFileTargetPath

Function TestProtoFileTargetPath

private/bufpkg/bufmodule/bufmodule_test.go:548–659  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

546}
547
548func TestProtoFileTargetPath(t *testing.T) {
549 t.Parallel()
550
551 ctx := t.Context()
552 bucket := testNewBucketForPathToData(
553 t,
554 map[string][]byte{
555 "a/1.proto": []byte(
556 `syntax = proto3; package a;`,
557 ),
558 "a/2.proto": []byte(
559 `syntax = proto3; package a;`,
560 ),
561 "also_a/1.proto": []byte(
562 `syntax = proto3; package a;`,
563 ),
564 "b/1.proto": []byte(
565 `syntax = proto3; package b;`,
566 ),
567 "b/2.proto": []byte(
568 `syntax = proto3; package b;`,
569 ),
570 },
571 )
572
573 moduleSetBuilder := bufmodule.NewModuleSetBuilder(ctx, slogtestext.NewLogger(t), bufmodule.NopModuleDataProvider, bufmodule.NopCommitProvider)
574 moduleSetBuilder.AddLocalModule(bucket, "module1", true)
575 moduleSet, err := moduleSetBuilder.Build()
576 require.NoError(t, err)
577 module1 := moduleSet.GetModuleForOpaqueID("module1")
578 require.NotNil(t, module1)
579 testFilePaths(
580 t,
581 module1,
582 "a/1.proto",
583 "a/2.proto",
584 "also_a/1.proto",
585 "b/1.proto",
586 "b/2.proto",
587 )
588 testTargetFilePaths(
589 t,
590 module1,
591 "a/1.proto",
592 "a/2.proto",
593 "also_a/1.proto",
594 "b/1.proto",
595 "b/2.proto",
596 )
597
598 // The single file a/1.proto
599 moduleSetBuilder = bufmodule.NewModuleSetBuilder(ctx, slogtestext.NewLogger(t), bufmodule.NopModuleDataProvider, bufmodule.NopCommitProvider)
600 moduleSetBuilder.AddLocalModule(
601 bucket,
602 "module1",
603 true,
604 bufmodule.LocalModuleWithProtoFileTargetPath(
605 "a/1.proto",

Callers

nothing calls this directly

Calls 9

AddLocalModuleMethod · 0.95
BuildMethod · 0.95
NewModuleSetBuilderFunction · 0.92
NewLoggerFunction · 0.92
testFilePathsFunction · 0.85
testTargetFilePathsFunction · 0.85
GetModuleForOpaqueIDMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…