commit
4deb845701
4 changed files with 14 additions and 11 deletions
2
.github/workflows/pr-test.yml
vendored
2
.github/workflows/pr-test.yml
vendored
|
|
@ -78,7 +78,7 @@ env:
|
|||
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
|
||||
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
|
||||
S3_BUCKET: ${{ secrets.S3_BUCKET }}
|
||||
S3_CACHE_PATH: /tmp/s3-cache
|
||||
S3_PUBLIC_URL: ${{ secrets.S3_PUBLIC_URL }}
|
||||
|
||||
jobs:
|
||||
UnitTest:
|
||||
|
|
|
|||
2
.github/workflows/unit-test.yml
vendored
2
.github/workflows/unit-test.yml
vendored
|
|
@ -82,7 +82,7 @@ env:
|
|||
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
|
||||
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
|
||||
S3_BUCKET: ${{ secrets.S3_BUCKET }}
|
||||
S3_CACHE_PATH: /tmp/s3-cache
|
||||
S3_PUBLIC_URL: ${{ secrets.S3_PUBLIC_URL }}
|
||||
|
||||
jobs:
|
||||
unit-test:
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ func (storage *Storage) Upload(ctx context.Context, fileID string, reader io.Rea
|
|||
ContentType: aws.String(contentType),
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to upload file: %w", err)
|
||||
return "", fmt.Errorf("failed to upload file %s: %w", fileID, err)
|
||||
}
|
||||
|
||||
return fileID, nil
|
||||
|
|
@ -144,7 +144,7 @@ func (storage *Storage) UploadChunk(ctx context.Context, fileID string, chunkInd
|
|||
ContentType: aws.String(contentType),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to upload chunk %d: %w", chunkIndex, err)
|
||||
return fmt.Errorf("failed to upload chunk %s %d: %w", fileID, chunkIndex, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -182,7 +182,7 @@ func (storage *Storage) MergeChunks(ctx context.Context, fileID string, totalChu
|
|||
_, err = io.Copy(&mergedContent, result.Body)
|
||||
result.Body.Close()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to copy chunk %d: %w", i, err)
|
||||
return fmt.Errorf("failed to copy chunk %s %d: %w", fileID, i, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ func (storage *Storage) MergeChunks(ctx context.Context, fileID string, totalChu
|
|||
ContentType: aws.String(contentType),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to upload merged file: %w", err)
|
||||
return fmt.Errorf("failed to upload merged file %s: %w", fileID, err)
|
||||
}
|
||||
|
||||
// Clean up chunks
|
||||
|
|
@ -227,7 +227,7 @@ func (storage *Storage) Reader(ctx context.Context, fileID string) (io.ReadClose
|
|||
Key: aws.String(key),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get file: %w", err)
|
||||
return nil, fmt.Errorf("failed to get file %s: %w", fileID, err)
|
||||
}
|
||||
|
||||
// If the file is a gzip file, decompress it
|
||||
|
|
@ -256,7 +256,7 @@ func (storage *Storage) Download(ctx context.Context, fileID string) (io.ReadClo
|
|||
Key: aws.String(key),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("failed to download file: %w", err)
|
||||
return nil, "", fmt.Errorf("failed to download file %s: %w", fileID, err)
|
||||
}
|
||||
|
||||
contentType := "application/octet-stream"
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -93,7 +94,7 @@ func TestS3Storage(t *testing.T) {
|
|||
storage, err := New(getS3Config())
|
||||
assert.NoError(t, err)
|
||||
|
||||
fileID := "test-chunked.txt"
|
||||
fileID := "test-chunked-" + uuid.New().String() + ".txt"
|
||||
content1 := []byte("chunk1")
|
||||
content2 := []byte("chunk2")
|
||||
|
||||
|
|
@ -128,7 +129,7 @@ func TestS3Storage(t *testing.T) {
|
|||
storage, err := New(getS3Config())
|
||||
assert.NoError(t, err)
|
||||
|
||||
fileID := "test-ops.txt"
|
||||
fileID := "test-ops-" + uuid.New().String() + ".txt"
|
||||
content := []byte("test content")
|
||||
|
||||
// Upload file
|
||||
|
|
@ -163,7 +164,9 @@ func TestS3Storage(t *testing.T) {
|
|||
storage, err := New(getS3Config())
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, _, err = storage.Download(context.Background(), "non-existent.txt")
|
||||
// Use UUID for non-existent file to avoid any potential conflicts
|
||||
nonExistentFileID := "non-existent-" + uuid.New().String() + ".txt"
|
||||
_, _, err = storage.Download(context.Background(), nonExistentFileID)
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue