Merge pull request #420 from fkautz/pr_out_api_test_now_states_which_driver_is_currently_running

master
Frederick F. Kautz IV 10 years ago
commit 224d53b3eb
  1. 26
      pkg/api/api_test.go

@ -21,9 +21,11 @@ import (
"encoding/xml" "encoding/xml"
"io" "io"
"io/ioutil" "io/ioutil"
"log"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
"reflect"
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
@ -31,6 +33,7 @@ import (
"github.com/minio-io/minio/pkg/api" "github.com/minio-io/minio/pkg/api"
"github.com/minio-io/minio/pkg/drivers" "github.com/minio-io/minio/pkg/drivers"
"github.com/minio-io/minio/pkg/drivers/file"
"github.com/minio-io/minio/pkg/drivers/memory" "github.com/minio-io/minio/pkg/drivers/memory"
"github.com/minio-io/minio/pkg/drivers/mocks" "github.com/minio-io/minio/pkg/drivers/mocks"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
@ -62,14 +65,22 @@ var _ = Suite(&MySuite{
var _ = Suite(&MySuite{ var _ = Suite(&MySuite{
initDriver: func() (drivers.Driver, string) { initDriver: func() (drivers.Driver, string) {
_, _, driver := memory.Start() root, _ := ioutil.TempDir(os.TempDir(), "minio-api-fs")
return driver, "" _, _, driver := file.Start(root)
return driver, root
}, },
}) })
func (s *MySuite) SetUpSuite(c *C) {
driver, root := s.initDriver()
if root != "" {
defer os.RemoveAll(root)
}
log.Println("Running API Suite:", reflect.TypeOf(driver))
}
func (s *MySuite) SetUpTest(c *C) { func (s *MySuite) SetUpTest(c *C) {
driver, root := s.initDriver() driver, root := s.initDriver()
s.Root = root
var typedDriver *mocks.Driver var typedDriver *mocks.Driver
switch driver := driver.(type) { switch driver := driver.(type) {
case *mocks.Driver: case *mocks.Driver:
@ -82,6 +93,7 @@ func (s *MySuite) SetUpTest(c *C) {
} }
} }
s.Driver = driver s.Driver = driver
s.Root = root
s.MockDriver = typedDriver s.MockDriver = typedDriver
} }
@ -92,10 +104,12 @@ func (s *MySuite) TearDownTest(c *C) {
driver.AssertExpectations(c) driver.AssertExpectations(c)
} }
} }
if s.Root != "" { root := strings.TrimSpace(s.Root)
if root != "" {
os.RemoveAll(s.Root) os.RemoveAll(s.Root)
} }
s.Driver = nil
s.Root = ""
} }
func (s *MySuite) TestNonExistantObject(c *C) { func (s *MySuite) TestNonExistantObject(c *C) {
@ -410,7 +424,7 @@ func (s *MySuite) TestPutObject(c *C) {
c.Assert(resources.IsTruncated, Equals, false) c.Assert(resources.IsTruncated, Equals, false)
c.Assert(err, Not(IsNil)) c.Assert(err, Not(IsNil))
date1 := time.Now() date1 := time.Now().Add(-time.Second)
// Put Bucket before - Put Object into a bucket // Put Bucket before - Put Object into a bucket
typedDriver.On("CreateBucket", "bucket").Return(nil).Once() typedDriver.On("CreateBucket", "bucket").Return(nil).Once()

Loading…
Cancel
Save