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

Function TestNoProtoFilesError

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

Source from the content-addressed store, hash-verified

503}
504
505func TestNoProtoFilesError(t *testing.T) {
506 t.Parallel()
507
508 ctx := t.Context()
509
510 moduleSet, err := bufmoduletesting.NewOmniProvider(
511 bufmoduletesting.ModuleData{
512 Name: "buf.build/foo/a",
513 PathToData: map[string][]byte{
514 "a.proto": []byte(
515 `syntax = proto3; package a;`,
516 ),
517 },
518 },
519 bufmoduletesting.ModuleData{
520 Name: "buf.build/foo/b",
521 PathToData: map[string][]byte{
522 "LICENSE": []byte(
523 "fake license",
524 ),
525 },
526 },
527 )
528 require.NoError(t, err)
529
530 moduleA := moduleSet.GetModuleForOpaqueID("buf.build/foo/a")
531 require.NotNil(t, moduleA)
532
533 checkError := func(err error) {
534 require.Error(t, err)
535 noProtoFilesError := &bufmodule.NoProtoFilesError{}
536 require.True(t, errors.As(err, &noProtoFilesError), err.Error())
537 require.Contains(
538 t,
539 "buf.build/foo/b",
540 noProtoFilesError.ModuleDescription,
541 )
542 }
543 moduleReadBucket := bufmodule.ModuleSetToModuleReadBucketWithOnlyProtoFiles(moduleSet)
544 err = moduleReadBucket.WalkFileInfos(ctx, func(bufmodule.FileInfo) error { return nil })
545 checkError(err)
546}
547
548func TestProtoFileTargetPath(t *testing.T) {
549 t.Parallel()

Callers

nothing calls this directly

Calls 5

NewOmniProviderFunction · 0.92
GetModuleForOpaqueIDMethod · 0.65
WalkFileInfosMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…