github.com/resonatecoop/id@v1.1.0-43/config/factory_test.go (about) 1 package config_test 2 3 import ( 4 "testing" 5 6 "github.com/resonatecoop/id/config" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 type Foo struct { 11 cnf *config.Config 12 } 13 14 func (b *Foo) LoadConfig() (*config.Config, error) { 15 return nil, nil 16 } 17 18 func (b *Foo) RefreshConfig(newCnf *config.Config) { 19 b.cnf = newCnf 20 } 21 22 func (b *Foo) InitConfigBackend() {} 23 24 func TestConfigReloading(t *testing.T) { 25 26 config.Cnf.Oauth.AuthCodeLifetime = 123 27 foo := &Foo{cnf: config.Cnf} 28 assert.Equal(t, 123, foo.cnf.Oauth.AuthCodeLifetime) 29 newCnf := &config.Config{Oauth: config.OauthConfig{AuthCodeLifetime: 9999}} 30 assert.Equal(t, 123, foo.cnf.Oauth.AuthCodeLifetime) 31 foo.RefreshConfig(newCnf) 32 assert.Equal(t, 9999, foo.cnf.Oauth.AuthCodeLifetime) 33 }