-
Notifications
You must be signed in to change notification settings - Fork 13
/
checker_test.go
41 lines (33 loc) · 1.03 KB
/
checker_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2015 Globo.com. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package config
import (
"bytes"
"errors"
"gopkg.in/check.v1"
)
type CheckerSuite struct{}
var _ = check.Suite(&CheckerSuite{})
func (s *CheckerSuite) TestCheckExecuteCheckerFunc(c *check.C) {
err := Check([]Checker{
func() error { return errors.New("Fake checker error") },
})
c.Assert(err, check.NotNil)
c.Assert(err.Error(), check.Equals, "Fake checker error")
}
func (s *CheckerSuite) TestCheckConsideringWarningsAsErrors(c *check.C) {
err := Check([]Checker{
func() error { return NewWarning("my warning") },
})
c.Assert(err, check.NotNil)
c.Assert(err.Error(), check.Equals, "my warning")
}
func (s *CheckerSuite) TestCheckWithWarnings(c *check.C) {
buf := bytes.NewBuffer(nil)
err := CheckWithWarnings([]Checker{
func() error { return NewWarning("my warning") },
}, buf)
c.Assert(err, check.IsNil)
c.Assert(buf.String(), check.Equals, "WARNING: my warning\n")
}