You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

84 lines
1.8 KiB

  1. package s3_test
  2. import (
  3. "github.com/goamz/goamz/aws"
  4. "github.com/goamz/goamz/s3"
  5. "github.com/goamz/goamz/s3/s3test"
  6. . "gopkg.in/check.v1"
  7. )
  8. type LocalServer struct {
  9. auth aws.Auth
  10. region aws.Region
  11. srv *s3test.Server
  12. config *s3test.Config
  13. }
  14. func (s *LocalServer) SetUp(c *C) {
  15. srv, err := s3test.NewServer(s.config)
  16. c.Assert(err, IsNil)
  17. c.Assert(srv, NotNil)
  18. s.srv = srv
  19. s.region = aws.Region{
  20. Name: "faux-region-1",
  21. S3Endpoint: srv.URL(),
  22. S3LocationConstraint: true, // s3test server requires a LocationConstraint
  23. }
  24. }
  25. // LocalServerSuite defines tests that will run
  26. // against the local s3test server. It includes
  27. // selected tests from ClientTests;
  28. // when the s3test functionality is sufficient, it should
  29. // include all of them, and ClientTests can be simply embedded.
  30. type LocalServerSuite struct {
  31. srv LocalServer
  32. clientTests ClientTests
  33. }
  34. var (
  35. // run tests twice, once in us-east-1 mode, once not.
  36. _ = Suite(&LocalServerSuite{
  37. srv: LocalServer{
  38. config: &s3test.Config{},
  39. },
  40. })
  41. _ = Suite(&LocalServerSuite{
  42. srv: LocalServer{
  43. config: &s3test.Config{
  44. Send409Conflict: true,
  45. },
  46. },
  47. })
  48. )
  49. func (s *LocalServerSuite) SetUpSuite(c *C) {
  50. s.srv.SetUp(c)
  51. s.clientTests.s3 = s3.New(s.srv.auth, s.srv.region)
  52. // TODO Sadly the fake server ignores auth completely right now. :-(
  53. s.clientTests.authIsBroken = true
  54. s.clientTests.Cleanup()
  55. }
  56. func (s *LocalServerSuite) TearDownTest(c *C) {
  57. s.clientTests.Cleanup()
  58. }
  59. func (s *LocalServerSuite) TestBasicFunctionality(c *C) {
  60. s.clientTests.TestBasicFunctionality(c)
  61. }
  62. func (s *LocalServerSuite) TestGetNotFound(c *C) {
  63. s.clientTests.TestGetNotFound(c)
  64. }
  65. func (s *LocalServerSuite) TestBucketList(c *C) {
  66. s.clientTests.TestBucketList(c)
  67. }
  68. func (s *LocalServerSuite) TestDoublePutBucket(c *C) {
  69. s.clientTests.TestDoublePutBucket(c)
  70. }