diff --git a/pkg/adapters/objstorage/localstorage/localstorage.go b/pkg/adapters/objstorage/localstorage/localstorage.go index e23d132..07f632a 100644 --- a/pkg/adapters/objstorage/localstorage/localstorage.go +++ b/pkg/adapters/objstorage/localstorage/localstorage.go @@ -60,22 +60,11 @@ func (storage *LocalStorage) Upload(workU *domain.WorkUnit) (*domain.UploadResul fullFilePath := filepath.Join(storage.path, workU.Prefix, workU.Filename) - file, err := os.Create(fullFilePath) - if err != nil { - return nil, fmt.Errorf("error creating file: %w", err) - } - defer file.Close() - - _, err = file.Write(workU.Data) + err = os.WriteFile(fullFilePath, workU.Data, os.ModePerm) if err != nil { return nil, fmt.Errorf("error writing data into file: %w", err) } - err = file.Sync() - if err != nil { - return nil, fmt.Errorf("error when syncing file: %w", err) - } - return &domain.UploadResult{ Bucket: "localstorage", Path: fullFilePath, diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index f8d23f4..f017566 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -196,33 +196,33 @@ func TestAppIntegration(t *testing.T) { testWithBatchSize(t, conf, 1, 1, 1) }) - // t.Run("single entry", func(t *testing.T) { - // testWithBatchSize(t, conf, 10) - // testWithBatchSize(t, conf, 18) - // testWithBatchSize(t, conf, 19) - // testWithBatchSize(t, conf, 20) - // testWithBatchSize(t, conf, 21) - // testWithBatchSize(t, conf, 55) - // }) - - // t.Run("dual entries", func(t *testing.T) { - // testWithBatchSize(t, conf, 11, 5) - // testWithBatchSize(t, conf, 11, 6) - // testWithBatchSize(t, conf, 10, 6) - // testWithBatchSize(t, conf, 12, 5) - // testWithBatchSize(t, conf, 13, 5) - // testWithBatchSize(t, conf, 55, 66) - // }) - - // t.Run("only big entries", func(t *testing.T) { - // testWithBatchSize(t, conf, - // 66, 67, 119) - // }) - - // t.Run("multiple entries", func(t *testing.T) { - // testWithBatchSize(t, conf, - // 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) - // }) + t.Run("single entry", func(t *testing.T) { + testWithBatchSize(t, conf, 10) + testWithBatchSize(t, conf, 18) + testWithBatchSize(t, conf, 19) + testWithBatchSize(t, conf, 20) + testWithBatchSize(t, conf, 21) + testWithBatchSize(t, conf, 55) + }) + + t.Run("dual entries", func(t *testing.T) { + testWithBatchSize(t, conf, 11, 5) + testWithBatchSize(t, conf, 11, 6) + testWithBatchSize(t, conf, 10, 6) + testWithBatchSize(t, conf, 12, 5) + testWithBatchSize(t, conf, 13, 5) + testWithBatchSize(t, conf, 55, 66) + }) + + t.Run("only big entries", func(t *testing.T) { + testWithBatchSize(t, conf, + 66, 67, 119) + }) + + t.Run("multiple entries", func(t *testing.T) { + testWithBatchSize(t, conf, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) + }) } func testWithBatchSize(t *testing.T, conf *config.Config, stringExemplarSizes ...int) {