diff --git a/core/server/api_container/server/api_container_service.go b/core/server/api_container/server/api_container_service.go index ef6bd1cd87..d82e98a173 100644 --- a/core/server/api_container/server/api_container_service.go +++ b/core/server/api_container/server/api_container_service.go @@ -904,7 +904,7 @@ func getTextRepresentation(reader io.Reader, lineCount int) (*string, error) { return nil, stacktrace.NewError("File has no text representation because '%v' is not printable", char) } } - textRepresentation.WriteString(line) + textRepresentation.WriteString(fmt.Sprintf("%s\n", line)) } if err := scanner.Err(); err != nil { diff --git a/core/server/api_container/server/api_container_service_test.go b/core/server/api_container/server/api_container_service_test.go index 30fc3f1aea..c4e66b0226 100644 --- a/core/server/api_container/server/api_container_service_test.go +++ b/core/server/api_container/server/api_container_service_test.go @@ -9,6 +9,7 @@ import ( "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/port_spec" "github.com/stretchr/testify/require" + "strings" "testing" ) @@ -35,3 +36,17 @@ func TestOneToOneApiAndPortSpecProtoMapping(t *testing.T) { seenPortSpecProtos[portSpecProto] = apiPortProto } } + +func TestGetTextRepresentation(t *testing.T) { + input := `my +line +input +` + expectedOutput := `my +line +` + output, err := getTextRepresentation(strings.NewReader(input), 2) + require.NoError(t, err) + require.NotNil(t, output) + require.Equal(t, expectedOutput, *output) +} diff --git a/internal_testsuites/golang/testsuite/upload_download_files_test/upload_download_file_test.go b/internal_testsuites/golang/testsuite/upload_download_files_test/upload_download_file_test.go index a5b553da52..8fdd1f3a39 100644 --- a/internal_testsuites/golang/testsuite/upload_download_files_test/upload_download_file_test.go +++ b/internal_testsuites/golang/testsuite/upload_download_files_test/upload_download_file_test.go @@ -23,7 +23,7 @@ const ( archiveDirectoryTestPattern = "upload-test-golang-" archiveSubDirectoryTestPattern = "sub-folder-" archiveFileTestPattern = "test-file-" - archiveTestFileContent = "This file is for testing purposes." + archiveTestFileContent = "This file is for testing purposes.\n" numberOfTempTestFilesToCreateInSubDir = 3 numberOfTempTestFilesToCreateInArchiveDir = 1