(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestNewModuleSetForProtoc(t *testing.T) { |
| 26 | t.Parallel() |
| 27 | |
| 28 | ctx := t.Context() |
| 29 | |
| 30 | moduleSet, err := NewModuleSetForProtoc( |
| 31 | ctx, |
| 32 | slogtestext.NewLogger(t), |
| 33 | storageos.NewProvider(), |
| 34 | []string{ |
| 35 | "testdata/basic/bsr/buf.testing/acme/date", |
| 36 | "testdata/basic/bsr/buf.testing/acme/extension", |
| 37 | "testdata/basic/workspacev1/common/geo/proto", |
| 38 | "testdata/basic/workspacev1/common/money/proto", |
| 39 | "testdata/basic/workspacev1/finance/bond/proto/root1", |
| 40 | "testdata/basic/workspacev1/finance/bond/proto/root2", |
| 41 | "testdata/basic/workspacev1/finance/portfolio/proto", |
| 42 | }, |
| 43 | []string{ |
| 44 | "testdata/basic/workspacev1/finance/portfolio/proto/acme/portfolio/v1/portfolio.proto", |
| 45 | }, |
| 46 | ) |
| 47 | require.NoError(t, err) |
| 48 | |
| 49 | modules := moduleSet.Modules() |
| 50 | require.Equal(t, 1, len(modules)) |
| 51 | module := modules[0] |
| 52 | require.Equal(t, ".", module.OpaqueID()) |
| 53 | require.True(t, module.IsTarget()) |
| 54 | |
| 55 | fileInfo, err := module.StatFileInfo(ctx, "acme/money/v1/currency_code.proto") |
| 56 | require.NoError(t, err) |
| 57 | require.False(t, fileInfo.IsTargetFile()) |
| 58 | fileInfo, err = module.StatFileInfo(ctx, "acme/money/v1/money.proto") |
| 59 | require.NoError(t, err) |
| 60 | require.False(t, fileInfo.IsTargetFile()) |
| 61 | fileInfo, err = module.StatFileInfo(ctx, "acme/bond/real/v1/bond.proto") |
| 62 | require.NoError(t, err) |
| 63 | require.False(t, fileInfo.IsTargetFile()) |
| 64 | fileInfo, err = module.StatFileInfo(ctx, "acme/portfolio/v1/portfolio.proto") |
| 65 | require.NoError(t, err) |
| 66 | require.True(t, fileInfo.IsTargetFile()) |
| 67 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…