feat: add dependency shutdown and configurable service endpoints
This commit is contained in:
@@ -2,8 +2,10 @@ package s3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.yuntuo.hk/k2safe/go-omni/internal/storagefixture"
|
||||
"git.yuntuo.hk/k2safe/go-omni/storage"
|
||||
"git.yuntuo.hk/k2safe/go-omni/storage/storagetest"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
@@ -24,7 +26,25 @@ func TestS3ProtocolAndR2Config(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
storagetest.Run(t, s)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
if _, err = s.Get(ctx, "open-config-missing"); !errors.Is(err, storage.ErrNotFound) {
|
||||
t.Fatal("configured client did not reach protocol fixture", err)
|
||||
}
|
||||
// Malformed-body cases intentionally cause SDK errors. Disable retries on
|
||||
// this test-owned client so randomized backoff cannot exhaust the shared
|
||||
// contract deadline. Open above still checks the production client config.
|
||||
client, err := minio.New(strings.TrimPrefix(server.URL, "https://"), &minio.Options{
|
||||
Creds: creds, Region: "us-east-1", Secure: true, Transport: server.Client().Transport, MaxRetries: 1,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
contractStore, err := New(client, "testbucket", 64)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
storagetest.Run(t, contractStore)
|
||||
cfg, err := R2Config(strings.Repeat("a", 32), "bucket", creds)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user