(t *testing.T)
| 30 | ) |
| 31 | |
| 32 | func 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) |
nothing calls this directly
no test coverage detected
searching dependent graphs…