mirror of
https://github.com/minio/minio.git
synced 2025-01-23 12:43:16 -05:00
Move atomic package to the top and simplify its tests
This commit is contained in:
parent
fb84335010
commit
b938e40fb5
@ -27,7 +27,9 @@ import (
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
type ControllerRPCSuite struct{}
|
||||
type ControllerRPCSuite struct {
|
||||
root string
|
||||
}
|
||||
|
||||
var _ = Suite(&ControllerRPCSuite{})
|
||||
|
||||
@ -39,6 +41,7 @@ var (
|
||||
func (s *ControllerRPCSuite) SetUpSuite(c *C) {
|
||||
root, err := ioutil.TempDir(os.TempDir(), "api-")
|
||||
c.Assert(err, IsNil)
|
||||
s.root = root
|
||||
auth.SetAuthConfigPath(root)
|
||||
|
||||
testControllerRPC = httptest.NewServer(getControllerRPCHandler())
|
||||
@ -48,6 +51,7 @@ func (s *ControllerRPCSuite) SetUpSuite(c *C) {
|
||||
}
|
||||
|
||||
func (s *ControllerRPCSuite) TearDownSuite(c *C) {
|
||||
os.RemoveAll(s.root)
|
||||
testServerRPC.Close()
|
||||
testControllerRPC.Close()
|
||||
}
|
||||
|
@ -27,29 +27,37 @@ import (
|
||||
|
||||
func Test(t *testing.T) { TestingT(t) }
|
||||
|
||||
type MySuite struct{}
|
||||
type MySuite struct {
|
||||
root string
|
||||
}
|
||||
|
||||
var _ = Suite(&MySuite{})
|
||||
|
||||
func (s *MySuite) TestAtomic(c *C) {
|
||||
func (s *MySuite) SetUpSuite(c *C) {
|
||||
root, err := ioutil.TempDir("/tmp", "atomic-")
|
||||
c.Assert(err, IsNil)
|
||||
f, err := FileCreate(filepath.Join(root, "testfile"))
|
||||
s.root = root
|
||||
}
|
||||
|
||||
func (s *MySuite) TearDownSuite(c *C) {
|
||||
os.RemoveAll(s.root)
|
||||
}
|
||||
|
||||
func (s *MySuite) TestAtomic(c *C) {
|
||||
f, err := FileCreate(filepath.Join(s.root, "testfile"))
|
||||
c.Assert(err, IsNil)
|
||||
_, err = os.Stat(filepath.Join(root, "testfile"))
|
||||
_, err = os.Stat(filepath.Join(s.root, "testfile"))
|
||||
c.Assert(err, Not(IsNil))
|
||||
err = f.Close()
|
||||
c.Assert(err, IsNil)
|
||||
_, err = os.Stat(filepath.Join(root, "testfile"))
|
||||
_, err = os.Stat(filepath.Join(s.root, "testfile"))
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
func (s *MySuite) TestAtomicPurge(c *C) {
|
||||
root, err := ioutil.TempDir("/tmp", "atomic-")
|
||||
f, err := FileCreate(filepath.Join(s.root, "purgefile"))
|
||||
c.Assert(err, IsNil)
|
||||
f, err := FileCreate(filepath.Join(root, "testfile"))
|
||||
c.Assert(err, IsNil)
|
||||
_, err = os.Stat(filepath.Join(root, "testfile"))
|
||||
_, err = os.Stat(filepath.Join(s.root, "purgefile"))
|
||||
c.Assert(err, Not(IsNil))
|
||||
err = f.CloseAndPurge()
|
||||
c.Assert(err, IsNil)
|
@ -25,7 +25,7 @@ import (
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/minio/minio/pkg/utils/atomic"
|
||||
"github.com/minio/minio/pkg/atomic"
|
||||
)
|
||||
|
||||
// IsValidDonut - verify donut name is correct
|
||||
|
@ -25,8 +25,8 @@ import (
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"github.com/minio/minio/pkg/atomic"
|
||||
"github.com/minio/minio/pkg/probe"
|
||||
"github.com/minio/minio/pkg/utils/atomic"
|
||||
)
|
||||
|
||||
// Disk container for disk parameters
|
||||
|
Loading…
x
Reference in New Issue
Block a user