(t *testing.T)
| 311 | } |
| 312 | |
| 313 | func TestModuleTargetFiles(t *testing.T) { |
| 314 | t.Parallel() |
| 315 | moduleSet, err := bufmoduletesting.NewModuleSet( |
| 316 | bufmoduletesting.ModuleData{ |
| 317 | Name: "buf.build/foo/a", |
| 318 | PathToData: map[string][]byte{ |
| 319 | "a.proto": []byte( |
| 320 | `syntax = "proto3"; package a; import "b.proto";`, |
| 321 | ), |
| 322 | }, |
| 323 | }, |
| 324 | bufmoduletesting.ModuleData{ |
| 325 | Name: "buf.build/foo/b", |
| 326 | PathToData: map[string][]byte{ |
| 327 | "b.proto": []byte( |
| 328 | `syntax = "proto3"; package b; import "c.proto";`, |
| 329 | ), |
| 330 | }, |
| 331 | }, |
| 332 | bufmoduletesting.ModuleData{ |
| 333 | Name: "buf.build/foo/c", |
| 334 | PathToData: map[string][]byte{ |
| 335 | "c.proto": []byte( |
| 336 | `syntax = "proto3"; package c;`, |
| 337 | ), |
| 338 | }, |
| 339 | }, |
| 340 | ) |
| 341 | require.NoError(t, err) |
| 342 | testTargetImageFiles := func(t *testing.T, want []string, opaqueID ...string) { |
| 343 | targetModuleSet := moduleSet |
| 344 | if len(opaqueID) > 0 { |
| 345 | var err error |
| 346 | targetModuleSet, err = moduleSet.WithTargetOpaqueIDs(opaqueID...) |
| 347 | require.NoError(t, err) |
| 348 | } |
| 349 | image, err := bufimage.BuildImage( |
| 350 | t.Context(), |
| 351 | slogtestext.NewLogger(t), |
| 352 | bufmodule.ModuleSetToModuleReadBucketWithOnlyProtoFiles(targetModuleSet), |
| 353 | ) |
| 354 | require.NoError(t, err) |
| 355 | assert.Equal(t, want, testGetImageFilePaths(image)) |
| 356 | } |
| 357 | testTargetImageFiles(t, []string{"a.proto", "b.proto", "c.proto"}) |
| 358 | testTargetImageFiles(t, []string{"a.proto", "b.proto", "c.proto"}, "buf.build/foo/a") |
| 359 | testTargetImageFiles(t, []string{"b.proto", "c.proto"}, "buf.build/foo/b") |
| 360 | testTargetImageFiles(t, []string{"c.proto"}, "buf.build/foo/c") |
| 361 | testTargetImageFiles(t, []string{"b.proto", "c.proto"}, "buf.build/foo/b", "buf.build/foo/c") |
| 362 | } |
| 363 | |
| 364 | func testCompare(t *testing.T, relDirPath string) { |
| 365 | dirPath := filepath.Join("testdata", relDirPath) |
nothing calls this directly
no test coverage detected
searching dependent graphs…