github.com/swisscom/cloudfoundry-cli@v7.1.0+incompatible/cf/util/testhelpers/configuration/fake_config_persistance.go (about) 1 package configuration 2 3 import ( 4 "code.cloudfoundry.org/cli/cf/configuration" 5 "code.cloudfoundry.org/cli/cf/configuration/coreconfig" 6 ) 7 8 type FakePersistor struct { 9 LoadReturns struct { 10 Data *coreconfig.Data 11 Err error 12 } 13 14 SaveArgs struct { 15 Data *coreconfig.Data 16 } 17 SaveReturns struct { 18 Err error 19 } 20 } 21 22 func NewFakePersistor() *FakePersistor { 23 return &FakePersistor{} 24 } 25 26 func (fp *FakePersistor) Load(data configuration.DataInterface) error { 27 if fp.LoadReturns.Data == nil { 28 fp.LoadReturns.Data = coreconfig.NewData() 29 } 30 return fp.LoadReturns.Err 31 } 32 33 func (fp *FakePersistor) Delete() {} 34 35 func (fp *FakePersistor) Exists() bool { 36 return true 37 } 38 39 func (fp *FakePersistor) Save(data configuration.DataInterface) (err error) { 40 fp.SaveArgs.Data = data.(*coreconfig.Data) 41 err = fp.SaveReturns.Err 42 return 43 }