Add tests for minio top level

This commit is contained in:
Harshavardhana
2015-09-18 23:32:31 -07:00
parent ec0fdf95e5
commit 7d8cfa0a77
5 changed files with 66 additions and 20 deletions
+26 -2
View File
@@ -16,8 +16,32 @@
package main
import . "gopkg.in/check.v1"
import (
"bytes"
"encoding/json"
"errors"
func (s *CmdTestSuite) TestLogger(c *C) {
"github.com/Sirupsen/logrus"
"github.com/minio/minio/pkg/probe"
. "gopkg.in/check.v1"
)
func (s *TestSuite) TestLogger(c *C) {
var buffer bytes.Buffer
var fields logrus.Fields
log.Out = &buffer
log.Formatter = new(logrus.JSONFormatter)
errorIf(probe.NewError(errors.New("Fake error")), "Failed with error.", nil)
err := json.Unmarshal(buffer.Bytes(), &fields)
c.Assert(err, IsNil)
c.Assert(fields["level"], Equals, "error")
msg, ok := fields["error"]
c.Assert(ok, Equals, true)
c.Assert(msg, Equals, "Fake error")
_, ok = fields["probe"]
c.Assert(ok, Equals, true)
}