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

Function TestBasic

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

Source from the content-addressed store, hash-verified

30)
31
32func TestBasic(t *testing.T) {
33 t.Parallel()
34
35 ctx := t.Context()
36
37 // This represents some external dependencies from the BSR.
38 bsrProvider, err := bufmoduletesting.NewOmniProvider(
39 bufmoduletesting.ModuleData{
40 Name: "buf.build/foo/extdep1",
41 PathToData: map[string][]byte{
42 "extdep1.proto": []byte(
43 `syntax = proto3; package extdep1;`,
44 ),
45 },
46 },
47 bufmoduletesting.ModuleData{
48 Name: "buf.build/foo/extdep2",
49 PathToData: map[string][]byte{
50 "extdep2.proto": []byte(
51 `syntax = proto3; package extdep2; import "extdep1.proto";`,
52 ),
53 },
54 },
55 bufmoduletesting.ModuleData{
56 Name: "buf.build/foo/extdep3",
57 PathToData: map[string][]byte{
58 "extdep3.proto": []byte(
59 `syntax = proto3; package extdep3; import "extdep4.proto";`,
60 ),
61 },
62 },
63 // This module is only a transitive remote dependency. It is only depended on by extdep3.
64 bufmoduletesting.ModuleData{
65 Name: "buf.build/foo/extdep4",
66 PathToData: map[string][]byte{
67 "extdep4.proto": []byte(
68 `syntax = proto3; package extdep4;`,
69 ),
70 },
71 },
72 // Adding in a module that exists remotely but we'll also have in the workspace.
73 //
74 // This one will import from extdep2 instead of the workspace importing from extdep1.
75 bufmoduletesting.ModuleData{
76 Name: "buf.build/bar/module2",
77 PathToData: map[string][]byte{
78 "module2.proto": []byte(
79 `syntax = proto3; package module2; import "extdep2.proto";`,
80 ),
81 },
82 },
83 )
84 require.NoError(t, err)
85
86 // This is the ModuleSetBuilder that will build the modules that we are going to test.
87 // This is replicating how a workspace would be built from remote dependencies and
88 // local sources.
89 moduleSetBuilder := bufmodule.NewModuleSetBuilder(ctx, slogtestext.NewLogger(t), bsrProvider, bsrProvider)

Callers

nothing calls this directly

Calls 15

AddRemoteModuleMethod · 0.95
AddLocalModuleMethod · 0.95
BuildMethod · 0.95
NewOmniProviderFunction · 0.92
NewModuleSetBuilderFunction · 0.92
NewLoggerFunction · 0.92
NewRefFunction · 0.92
NewFullNameFunction · 0.92
LocalModuleWithFullNameFunction · 0.92
ModuleSetOpaqueIDsFunction · 0.92
ModuleSetTargetOpaqueIDsFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…