Merge pull request #859 from harshavardhana/atomic-test

Move atomic package to the top and simplify its tests
master
Harshavardhana 9 years ago
commit 39e2209755
  1. 6
      controller_rpc_test.go
  2. 0
      pkg/atomic/atomic.go
  3. 26
      pkg/atomic/atomic_test.go
  4. 2
      pkg/donut/common.go
  5. 2
      pkg/donut/disk/disk.go

@ -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-")
c.Assert(err, IsNil)
f, err := FileCreate(filepath.Join(root, "testfile"))
f, err := FileCreate(filepath.Join(s.root, "purgefile"))
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…
Cancel
Save