2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-11 21:57:58 +00:00
restic/backend/s3_test.go

43 lines
660 B
Go
Raw Normal View History

2015-05-15 21:53:00 +00:00
package backend_test
import (
2015-12-28 23:27:29 +00:00
"net/url"
2015-12-28 17:23:02 +00:00
"os"
2015-05-15 21:53:00 +00:00
"testing"
"github.com/restic/restic/backend/s3"
. "github.com/restic/restic/test"
2015-05-15 21:53:00 +00:00
)
type deleter interface {
Delete() error
}
2015-05-15 21:53:00 +00:00
func TestS3Backend(t *testing.T) {
if TestS3Server == "" {
t.Skip("s3 test server not available")
}
2015-12-28 23:27:29 +00:00
url, err := url.Parse(TestS3Server)
OK(t, err)
cfg := s3.Config{
Endpoint: url.Host,
Bucket: "restictestbucket",
KeyID: os.Getenv("AWS_ACCESS_KEY_ID"),
Secret: os.Getenv("AWS_SECRET_ACCESS_KEY"),
}
if url.Scheme == "http" {
cfg.UseHTTP = true
}
be, err := s3.Open(cfg)
OK(t, err)
testBackend(be, t)
del := be.(deleter)
OK(t, del.Delete())
2015-05-15 21:53:00 +00:00
}