1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-27 10:17:58 +00:00
restic/backend/s3_test.go

55 lines
1 KiB
Go
Raw Normal View History

2015-05-15 21:53:00 +00:00
package backend_test
import (
"testing"
"gopkg.in/amz.v3/aws"
"gopkg.in/amz.v3/s3"
"gopkg.in/amz.v3/s3/s3test"
2015-05-15 21:53:00 +00:00
bes3 "github.com/restic/restic/backend/s3"
. "github.com/restic/restic/test"
)
type LocalServer struct {
auth aws.Auth
region aws.Region
srv *s3test.Server
config *s3test.Config
}
var s LocalServer
2015-05-15 21:53:00 +00:00
func setupS3Backend(t *testing.T) *bes3.S3Backend {
s.config = &s3test.Config{
Send409Conflict: true,
}
srv, err := s3test.NewServer(s.config)
2015-05-15 21:53:00 +00:00
OK(t, err)
s.srv = srv
2015-05-15 21:53:00 +00:00
s.region = aws.Region{
Name: "faux-region-1",
S3Endpoint: srv.URL(),
S3LocationConstraint: true, // s3test server requires a LocationConstraint
}
2015-05-15 21:53:00 +00:00
2015-08-26 12:44:00 +00:00
s.auth = aws.Auth{"abc", "123"}
2015-05-15 21:53:00 +00:00
service := s3.New(s.auth, s.region)
2015-08-26 12:44:00 +00:00
bucket, berr := service.Bucket("testbucket")
2015-08-26 12:54:39 +00:00
OK(t, berr)
err = bucket.PutBucket("private")
OK(t, err)
t.Logf("created s3 backend locally")
2015-05-15 21:53:00 +00:00
return bes3.OpenS3Bucket(bucket, "testbucket")
2015-05-15 21:53:00 +00:00
}
func TestS3Backend(t *testing.T) {
s := setupS3Backend(t)
testBackend(s, t)
}