(t *testing.T, expectedFilePathToInfo map[string]expectedFileInfo, buildArgs ...string)
| 1749 | } |
| 1750 | |
| 1751 | func requireBuildOutputFilePaths(t *testing.T, expectedFilePathToInfo map[string]expectedFileInfo, buildArgs ...string) { |
| 1752 | stdout := bytes.NewBuffer(nil) |
| 1753 | stderr := bytes.NewBuffer(nil) |
| 1754 | appcmdtesting.Run( |
| 1755 | t, |
| 1756 | func(use string) *appcmd.Command { return newRootCommand(use) }, |
| 1757 | appcmdtesting.WithExpectedExitCode(0), |
| 1758 | appcmdtesting.WithEnv(internaltesting.NewEnvFunc(t)), |
| 1759 | appcmdtesting.WithStdout(stdout), |
| 1760 | appcmdtesting.WithStderr(stderr), |
| 1761 | appcmdtesting.WithArgs(append( |
| 1762 | []string{ |
| 1763 | "build", |
| 1764 | "-o=-#format=binpb", |
| 1765 | }, |
| 1766 | buildArgs..., |
| 1767 | )...), |
| 1768 | ) |
| 1769 | outputImage := &imagev1.Image{} |
| 1770 | require.NoError(t, protoencoding.NewWireUnmarshaler(nil).Unmarshal(stdout.Bytes(), outputImage)) |
| 1771 | |
| 1772 | filesToCheck := xslices.ToStructMap(xslices.MapKeysToSlice(expectedFilePathToInfo)) |
| 1773 | |
| 1774 | for _, imageFile := range outputImage.GetFile() { |
| 1775 | filePath := imageFile.GetName() |
| 1776 | expectedFileInfo, ok := expectedFilePathToInfo[filePath] |
| 1777 | require.Truef(t, ok, "unexpected file in the image built: %s", filePath) |
| 1778 | require.Equal(t, expectedFileInfo.isImport, imageFile.GetBufExtension().GetIsImport()) |
| 1779 | if expectedFileInfo.moduleFullName != "" { |
| 1780 | moduleName := imageFile.GetBufExtension().GetModuleInfo().GetName() |
| 1781 | require.NotNil(t, moduleName) |
| 1782 | require.Equal(t, expectedFileInfo.moduleFullName, fmt.Sprintf("%s/%s/%s", moduleName.GetRemote(), moduleName.GetOwner(), moduleName.GetRepository())) |
| 1783 | } else { |
| 1784 | require.Nil(t, imageFile.GetBufExtension().GetModuleInfo().GetName()) |
| 1785 | } |
| 1786 | delete(filesToCheck, filePath) |
| 1787 | } |
| 1788 | require.Zerof(t, len(filesToCheck), "expected files missing from image built: %v", xslices.MapKeysToSortedSlice(filesToCheck)) |
| 1789 | } |
no test coverage detected
searching dependent graphs…