2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 11:28:54 +00:00
restic/backend/s3_test.go

54 lines
1.0 KiB
Go
Raw Normal View History

2015-05-15 21:53:00 +00:00
package backend_test
import (
"testing"
"github.com/mitchellh/goamz/aws"
"github.com/mitchellh/goamz/s3"
"github.com/mitchellh/goamz/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
s.auth = aws.Auth{"abc", "123", ""}
2015-05-15 21:53:00 +00:00
service := s3.New(s.auth, s.region)
bucket := service.Bucket("testbucket")
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)
}