File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
internal/features/storages/models/s3 Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 22 go run cmd/main.go
33
44test :
5- go test -count=1 ./ internal/ ...
5+ go test -p=1 - count=1 -failfast . \ i nternal\ . ..
66
77lint :
88 golangci-lint fmt && golangci-lint run
Original file line number Diff line number Diff line change 11package s3_storage
22
33import (
4+ "bytes"
45 "context"
56 "errors"
67 "fmt"
@@ -129,7 +130,7 @@ func (s *S3Storage) TestConnection() error {
129130 return err
130131 }
131132
132- // Create a context with 5 second timeout
133+ // Create a context with 10 second timeout
133134 ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
134135 defer cancel ()
135136
@@ -147,6 +148,35 @@ func (s *S3Storage) TestConnection() error {
147148 return fmt .Errorf ("bucket '%s' does not exist" , s .S3Bucket )
148149 }
149150
151+ // Test write and delete permissions by uploading and removing a small test file
152+ testFileID := uuid .New ().String () + "-test"
153+ testData := []byte ("test connection" )
154+ testReader := bytes .NewReader (testData )
155+
156+ // Upload test file
157+ _ , err = client .PutObject (
158+ ctx ,
159+ s .S3Bucket ,
160+ testFileID ,
161+ testReader ,
162+ int64 (len (testData )),
163+ minio.PutObjectOptions {},
164+ )
165+ if err != nil {
166+ return fmt .Errorf ("failed to upload test file to S3: %w" , err )
167+ }
168+
169+ // Delete test file
170+ err = client .RemoveObject (
171+ ctx ,
172+ s .S3Bucket ,
173+ testFileID ,
174+ minio.RemoveObjectOptions {},
175+ )
176+ if err != nil {
177+ return fmt .Errorf ("failed to delete test file from S3: %w" , err )
178+ }
179+
150180 return nil
151181}
152182
You can’t perform that action at this time.
0 commit comments