Exemple #1
0
func (s *ManagerTestSuite) TestList() {
	assert.Equal(s.T(), []string{}, s.manager.List())

	l := logger_mock.New()
	assert.Nil(s.T(), s.manager.Register("mock", l))
	assert.Equal(s.T(), []string{"mock"}, s.manager.List())
}
Exemple #2
0
func (s *ManagerTestSuite) TestDisable() {
	// setup
	l := logger_mock.New()
	s.manager.Register("mock", l)

	// disable
	assert.Nil(s.T(), s.manager.Disable("mock"))
	s.testIsEnabled("mock", false, nil)

	// inexistent
	assert.NotNil(s.T(), s.manager.Disable("inexistent"))
}
Exemple #3
0
func (s *ManagerTestSuite) TestDeregister() {
	// setup
	l := logger_mock.New()
	s.manager.Register("mock", l)

	// deregister
	assert.Nil(s.T(), s.manager.Deregister("mock"))
	assert.Equal(s.T(), []string{}, s.manager.List())

	// inexistent
	assert.NotNil(s.T(), s.manager.Deregister("inexistent"))
}
Exemple #4
0
func (s *ManagerTestSuite) TestRegister() {
	l := logger_mock.New()
	assert.Nil(s.T(), s.manager.Register("mock", l))
	assert.Equal(s.T(), []string{"mock"}, s.manager.List())
	s.testIsEnabled("mock", true, nil)

	// duplicate
	assert.Nil(s.T(), s.manager.Register("mock", l))
	assert.Equal(s.T(), []string{"mock"}, s.manager.List())
	s.testIsEnabled("mock", true, nil)

	// nil
	assert.NotNil(s.T(), s.manager.Register("mock", nil))
}
Exemple #5
0
func (s *ManagerTestSuite) TestIsEnabled() {
	// setup
	l := logger_mock.New()
	s.manager.Register("mock", l)

	// enabled logger
	s.testIsEnabled("mock", true, nil)

	// disabled logger
	s.manager.Disable("mock")
	s.testIsEnabled("mock", false, nil)

	// inexistent logger
	s.testIsEnabled("inexistent", false, fmt.Errorf("error"))
}
Exemple #6
0
func (s *ManagerTestSuite) TestEnable() {
	// setup
	l := logger_mock.New()
	s.manager.Register("mock", l)

	// registered logger is enabled by default
	s.testIsEnabled("mock", true, nil)

	// enable a disabled logger
	s.manager.Disable("mock")
	assert.Nil(s.T(), s.manager.Enable("mock"))
	s.testIsEnabled("mock", true, nil)

	// inexistent
	assert.NotNil(s.T(), s.manager.Enable("inexistent"))
}
Exemple #7
0
func (s *LoggerTestSuite) TestNew() {
	l := mock.New()
	assert.NotNil(s.T(), l)
}