Documentation
¶
Overview ¶
Package s3test provides a lightweight in-memory S3-compatible server for unit tests, backed by gofakes3 over an httptest.Server.
Use New to start a server. It is automatically shut down when the test completes. Point an objectstore S3 config at it via Server.Endpoint:
srv := s3test.New(t)
client, err := objectstore.NewWithConfig(&objectstore.Config{
Backend: objectstore.BackendS3,
Bucket: "my-bucket",
Endpoint: srv.Endpoint(),
Region: s3test.Region,
PathStyle: true,
S3Credentials: &objectstore.S3Credentials{
AccessKeyID: s3test.AccessKeyID,
SecretAccessKey: s3test.SecretAccessKey,
},
})
Index ¶
Constants ¶
const ( AccessKeyID = "test" SecretAccessKey = "test" Region = "us-east-1" )
Dummy credentials and region for the in-memory server. gofakes3 does not verify signatures, but the AWS SDK still requires a credential and region to construct a client, so tests pass these through.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an in-memory S3-compatible server backed by gofakes3.
func New ¶
New starts an in-memory S3 server and registers tb.Cleanup to shut it down when the test completes. Buckets are created automatically on first use, so tests need not provision them up front.
func (*Server) Backend ¶
Backend returns the underlying gofakes3.Backend for tests that need to seed or inspect objects directly without going through the S3 client.