Пример #1
0
func TestDynamicConfiguratonValidateShouldFailNilConf(t *testing.T) {
	assert := assert.New(t)

	dc := config.DynamicConfiguration{
		Type: "test",
		Conf: nil,
	}

	err := dc.Validate()
	assert.NotNil(err)
}
Пример #2
0
func TestDynamicConfiguratonDefaultShouldIgnoreNilConf(t *testing.T) {
	assert := assert.New(t)

	dc := config.DynamicConfiguration{
		Type: "test",
		Conf: nil,
	}

	dc.Default()
	//No panics means pass
	assert.True(true)
}
Пример #3
0
func TestDynamicConfiguratonShouldDefault(t *testing.T) {

	mockConf := new(mocks.Configuration)

	dc := config.DynamicConfiguration{
		Type: "test",
		Conf: mockConf,
	}

	mockConf.On("Default").Return()

	dc.Default()

	mockConf.Mock.AssertExpectations(t)

}
Пример #4
0
func TestDynamicConfiguratonShouldValidate(t *testing.T) {
	assert := assert.New(t)

	mockConf := new(mocks.Configuration)

	dc := config.DynamicConfiguration{
		Type: "test",
		Conf: mockConf,
	}

	mockConf.On("Validate").Return(nil)

	err := dc.Validate()
	assert.Nil(err)

	mockConf.Mock.AssertExpectations(t)

}