github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/internal/testhelpers/config_test/config.go (about) 1 package config_test 2 3 import ( 4 "github.com/ActiveState/cli/internal/keypairs" 5 ) 6 7 type Mock struct { 8 keypairs.Configurable 9 cfg map[string]interface{} 10 } 11 12 func (m *Mock) ConfigPath() string { 13 return "" 14 } 15 16 func (m *Mock) Close() error { 17 return nil 18 } 19 20 func (m *Mock) Set(key string, value interface{}) error { 21 if m.cfg == nil { 22 m.cfg = make(map[string]interface{}) 23 } 24 25 m.cfg[key] = value 26 27 return nil 28 } 29 30 func (m *Mock) GetString(key string) string { 31 if value, found := m.cfg[key]; found { 32 return value.(string) 33 } else { 34 return "" 35 } 36 } 37 38 func (m *Mock) GetBool(key string) bool { 39 value, found := m.cfg[key] 40 return found && value.(bool) 41 }