From 08142fa35252d66d261947febb20069dd3be8aae Mon Sep 17 00:00:00 2001 From: plastikfan Date: Thu, 4 Jan 2024 12:20:04 +0000 Subject: [PATCH] ref(proxy): move config into command pkg (#94) --- src/app/command/bootstrap.go | 26 ++- src/app/{proxy => command}/config-defaults.go | 43 +++-- src/app/command/config-readers.go | 8 +- src/app/command/config.go | 113 +++++++++++++ src/app/command/shrink-cmd_test.go | 9 + src/app/mocks/mocks-config.go | 41 ++++- src/app/proxy/config.go | 109 +----------- src/app/proxy/controller-sampler_test.go | 9 - src/app/proxy/controller.go | 4 +- src/app/proxy/enter-shrink.go | 2 +- src/internal/helpers/mock-config-data.go | 155 ++++++++++++++++-- src/internal/helpers/test-utils.go | 10 +- 12 files changed, 369 insertions(+), 160 deletions(-) rename src/app/{proxy => command}/config-defaults.go (62%) create mode 100644 src/app/command/config.go diff --git a/src/app/command/bootstrap.go b/src/app/command/bootstrap.go index 62ca580..2d76a7b 100644 --- a/src/app/command/bootstrap.go +++ b/src/app/command/bootstrap.go @@ -3,6 +3,7 @@ package command import ( "fmt" "os" + "path/filepath" "github.com/cubiest/jibberjabber" "github.com/samber/lo" @@ -18,9 +19,28 @@ import ( "github.com/snivilised/extendio/xfs/utils" "github.com/snivilised/pixa/src/app/proxy" "github.com/snivilised/pixa/src/i18n" - "github.com/snivilised/pixa/src/internal/helpers" ) +func ResolvePath(path string) string { + if path == "" { + return path + } + + result := path + + if result[0] == '~' { + if h, err := os.UserHomeDir(); err == nil { + result = filepath.Join(h, result[1:]) + } + } else { + if absolute, absErr := filepath.Abs(path); absErr == nil { + result = absolute + } + } + + return result +} + type LocaleDetector interface { Scan() language.Tag } @@ -43,7 +63,7 @@ func validatePositionalArgs(cmd *cobra.Command, args []string) error { return err } - directory := helpers.ResolvePath(args[0]) + directory := ResolvePath(args[0]) if !utils.Exists(directory) { return xi18n.NewPathNotFoundError("shrink directory", directory) @@ -137,7 +157,7 @@ func (b *Bootstrap) Root(options ...ConfigureOptionFn) *cobra.Command { fmt.Printf(" ===> 🌷🌷🌷 Root Command...\n") inputs := b.getRootInputs() - inputs.ParamSet.Native.Directory = helpers.ResolvePath(args[0]) + inputs.ParamSet.Native.Directory = ResolvePath(args[0]) if inputs.WorkerPoolFam.Native.CPU { inputs.WorkerPoolFam.Native.NoWorkers = 0 diff --git a/src/app/proxy/config-defaults.go b/src/app/command/config-defaults.go similarity index 62% rename from src/app/proxy/config-defaults.go rename to src/app/command/config-defaults.go index 58f50b1..64f94e8 100644 --- a/src/app/proxy/config-defaults.go +++ b/src/app/command/config-defaults.go @@ -1,7 +1,8 @@ -package proxy +package command import ( "github.com/snivilised/cobrass/src/clif" + "github.com/snivilised/pixa/src/app/proxy" ) const ( @@ -10,10 +11,25 @@ const ( defaultNoProgramRetries = 2 ) +type ( + defaultSchemes map[string]proxy.SchemeConfig // should be the proxy interface + defaultSchemesConfig struct { + schemes defaultSchemes + } + + defaultSchemeConfig struct { + profiles []string + } +) + +func (cfg defaultSchemeConfig) Profiles() []string { + return cfg.profiles +} + var ( DefaultProfilesConfig *MsProfilesConfig DefaultSamplerConfig *MsSamplerConfig - DefaultSchemesConfig *MsSchemesConfig + DefaultSchemesConfig *defaultSchemesConfig DefaultAdvancedConfig *MsAdvancedConfig ) @@ -22,7 +38,7 @@ func init() { // values that don't mean anything. Update to real useable defaults // DefaultProfilesConfig = &MsProfilesConfig{ - Profiles: ProfilesConfigMap{ + Profiles: proxy.ProfilesConfigMap{ "blur": clif.ChangedFlagsMap{ "strip": "true", "interlace": "plane", @@ -43,15 +59,18 @@ func init() { }, } - DefaultSchemesConfig = &MsSchemesConfig{ - "blur-sf": MsSchemeConfig{ - Profiles: []string{"blur", "sf"}, - }, - "adaptive-sf": MsSchemeConfig{ - Profiles: []string{"adaptive", "sf"}, - }, - "adaptive-blur": MsSchemeConfig{ - Profiles: []string{"adaptive", "blur"}, + // tbd: repatriate MsSchemesConfig + DefaultSchemesConfig = &defaultSchemesConfig{ + schemes: defaultSchemes{ + "blur-sf": &defaultSchemeConfig{ + profiles: []string{"blur", "sf"}, + }, + "adaptive-sf": &defaultSchemeConfig{ + profiles: []string{"adaptive", "sf"}, + }, + "adaptive-blur": &defaultSchemeConfig{ + profiles: []string{"adaptive", "blur"}, + }, }, } diff --git a/src/app/command/config-readers.go b/src/app/command/config-readers.go index 3e29cae..646d11d 100644 --- a/src/app/command/config-readers.go +++ b/src/app/command/config-readers.go @@ -16,7 +16,7 @@ func (r *MsProfilesConfigReader) Read(viper configuration.ViperConfig) (proxy.Pr // the config, but extendio is not aware of config, so it can't // check. Instead, we can check here. // - profilesCFG := &proxy.MsProfilesConfig{ + profilesCFG := &MsProfilesConfig{ Profiles: make(proxy.ProfilesConfigMap), } @@ -43,7 +43,7 @@ type MsSchemesConfigReader struct{} func (r *MsSchemesConfigReader) Read(viper configuration.ViperConfig) (proxy.SchemesConfig, error) { var ( - schemesCFG proxy.MsSchemesConfig + schemesCFG MsSchemesConfig ) err := viper.UnmarshalKey("schemes", &schemesCFG) @@ -55,7 +55,7 @@ type MsSamplerConfigReader struct{} func (r *MsSamplerConfigReader) Read(viper configuration.ViperConfig) (proxy.SamplerConfig, error) { var ( - samplerCFG proxy.MsSamplerConfig + samplerCFG MsSamplerConfig ) err := viper.UnmarshalKey("sampler", &samplerCFG) @@ -67,7 +67,7 @@ type MsAdvancedConfigReader struct{} func (r *MsAdvancedConfigReader) Read(viper configuration.ViperConfig) (proxy.AdvancedConfig, error) { var ( - advancedCFG proxy.MsAdvancedConfig + advancedCFG MsAdvancedConfig ) err := viper.UnmarshalKey("advanced", &advancedCFG) diff --git a/src/app/command/config.go b/src/app/command/config.go new file mode 100644 index 0000000..622a04a --- /dev/null +++ b/src/app/command/config.go @@ -0,0 +1,113 @@ +package command + +import ( + "fmt" + "time" + + "github.com/snivilised/cobrass/src/clif" + "github.com/snivilised/pixa/src/app/proxy" +) + +type MsProfilesConfig struct { + Profiles proxy.ProfilesConfigMap +} + +func (cfg MsProfilesConfig) Profile(name string) (clif.ChangedFlagsMap, bool) { + profile, found := cfg.Profiles[name] + + return profile, found +} + +type ( + MsSchemeConfig struct { + Profiles []string `mapstructure:"profiles"` + } + + MsSchemesConfig map[string]proxy.SchemeConfig +) + +func (cfg MsSchemesConfig) Validate(name string, profiles proxy.ProfilesConfig) error { + if name == "" { + return nil + } + + var ( + found bool + scheme proxy.SchemeConfig + ) + + if scheme, found = cfg[name]; !found { + return fmt.Errorf("scheme: '%v' not found in config", name) + } + + for _, p := range scheme.Profiles() { + if _, found := profiles.Profile(p); !found { + return fmt.Errorf("profile(referenced by scheme: '%v'): '%v' not found in config", + name, p, + ) + } + } + + return nil +} + +func (cfg MsSchemesConfig) Scheme(name string) (proxy.SchemeConfig, bool) { + config, found := cfg[name] + + return config, found +} + +type MsSamplerConfig struct { + Files uint `mapstructure:"files"` + Folders uint `mapstructure:"folders"` +} + +func (cfg *MsSamplerConfig) NoFiles() uint { + return cfg.Files +} + +func (cfg *MsSamplerConfig) NoFolders() uint { + return cfg.Folders +} + +type MsLabelsConfig struct { + Adhoc string `mapstructure:"adhoc"` + Journal string `mapstructure:"journal-suffix"` + Legacy string `mapstructure:"legacy"` + Trash string `mapstructure:"trash"` +} + +type MsAdvancedConfig struct { + Abort bool `mapstructure:"abort-on-error"` + Timeout string `mapstructure:"program-timeout"` + NoProgramRetries uint `mapstructure:"no-program-retries"` + Labels MsLabelsConfig `mapstructure:"labels"` +} + +func (cfg *MsAdvancedConfig) AbortOnError() bool { + return cfg.Abort +} + +func (cfg *MsAdvancedConfig) ProgramTimeout() (duration time.Duration, err error) { + return time.ParseDuration(cfg.Timeout) +} + +func (cfg *MsAdvancedConfig) NoRetries() uint { + return cfg.NoProgramRetries +} + +func (cfg *MsAdvancedConfig) AdhocLabel() string { + return cfg.Labels.Adhoc +} + +func (cfg *MsAdvancedConfig) JournalLabel() string { + return cfg.Labels.Journal +} + +func (cfg *MsAdvancedConfig) LegacyLabel() string { + return cfg.Labels.Legacy +} + +func (cfg *MsAdvancedConfig) TrashLabel() string { + return cfg.Labels.Trash +} diff --git a/src/app/command/shrink-cmd_test.go b/src/app/command/shrink-cmd_test.go index b49deb6..7396e39 100644 --- a/src/app/command/shrink-cmd_test.go +++ b/src/app/command/shrink-cmd_test.go @@ -10,12 +10,21 @@ import ( cmocks "github.com/snivilised/cobrass/src/assistant/mocks" "github.com/snivilised/pixa/src/app/command" "github.com/snivilised/pixa/src/app/mocks" + "github.com/snivilised/pixa/src/app/proxy" "github.com/snivilised/pixa/src/internal/helpers" "go.uber.org/mock/gomock" "github.com/snivilised/extendio/xfs/storage" ) +var ( + _ proxy.ProfilesConfig = &command.MsProfilesConfig{} + _ proxy.SamplerConfig = &command.MsSamplerConfig{} + _ proxy.ProfilesConfigReader = &command.MsProfilesConfigReader{} + _ proxy.SamplerConfigReader = &command.MsSamplerConfigReader{} + _ proxy.AdvancedConfigReader = &command.MsAdvancedConfigReader{} +) + const ( BackyardWorldsPlanet9Scan01 = "nasa/exo/Backyard Worlds - Planet 9/sessions/scan-01" ) diff --git a/src/app/mocks/mocks-config.go b/src/app/mocks/mocks-config.go index 3aaa88b..87e8224 100644 --- a/src/app/mocks/mocks-config.go +++ b/src/app/mocks/mocks-config.go @@ -94,6 +94,43 @@ func (mr *MockProfilesConfigReaderMockRecorder) Read(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockProfilesConfigReader)(nil).Read), arg0) } +// MockSchemeConfig is a mock of SchemeConfig interface. +type MockSchemeConfig struct { + ctrl *gomock.Controller + recorder *MockSchemeConfigMockRecorder +} + +// MockSchemeConfigMockRecorder is the mock recorder for MockSchemeConfig. +type MockSchemeConfigMockRecorder struct { + mock *MockSchemeConfig +} + +// NewMockSchemeConfig creates a new mock instance. +func NewMockSchemeConfig(ctrl *gomock.Controller) *MockSchemeConfig { + mock := &MockSchemeConfig{ctrl: ctrl} + mock.recorder = &MockSchemeConfigMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSchemeConfig) EXPECT() *MockSchemeConfigMockRecorder { + return m.recorder +} + +// Profiles mocks base method. +func (m *MockSchemeConfig) Profiles() []string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Profiles") + ret0, _ := ret[0].([]string) + return ret0 +} + +// Profiles indicates an expected call of Profiles. +func (mr *MockSchemeConfigMockRecorder) Profiles() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Profiles", reflect.TypeOf((*MockSchemeConfig)(nil).Profiles)) +} + // MockSchemesConfig is a mock of SchemesConfig interface. type MockSchemesConfig struct { ctrl *gomock.Controller @@ -118,10 +155,10 @@ func (m *MockSchemesConfig) EXPECT() *MockSchemesConfigMockRecorder { } // Scheme mocks base method. -func (m *MockSchemesConfig) Scheme(name string) (proxy.MsSchemeConfig, bool) { +func (m *MockSchemesConfig) Scheme(name string) (proxy.SchemeConfig, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Scheme", name) - ret0, _ := ret[0].(proxy.MsSchemeConfig) + ret0, _ := ret[0].(proxy.SchemeConfig) ret1, _ := ret[1].(bool) return ret0, ret1 } diff --git a/src/app/proxy/config.go b/src/app/proxy/config.go index a523076..982090b 100644 --- a/src/app/proxy/config.go +++ b/src/app/proxy/config.go @@ -1,7 +1,6 @@ package proxy import ( - "fmt" "time" "github.com/snivilised/cobrass/src/assistant/configuration" @@ -11,12 +10,6 @@ import ( //go:generate mockgen -destination ../mocks/mocks-config.go -package mocks -source config.go type ( - MsSchemeConfig struct { - Profiles []string `mapstructure:"profiles"` - } - - MsSchemesConfig map[string]MsSchemeConfig - ProfilesConfig interface { Profile(name string) (clif.ChangedFlagsMap, bool) } @@ -25,9 +18,13 @@ type ( Read(configuration.ViperConfig) (ProfilesConfig, error) } + SchemeConfig interface { + Profiles() []string + } + SchemesConfig interface { Validate(name string, profiles ProfilesConfig) error - Scheme(name string) (MsSchemeConfig, bool) + Scheme(name string) (SchemeConfig, bool) } SchemesConfigReader interface { @@ -57,99 +54,3 @@ type ( Read(configuration.ViperConfig) (AdvancedConfig, error) } ) - -type MsProfilesConfig struct { - Profiles ProfilesConfigMap -} - -func (cfg MsProfilesConfig) Profile(name string) (clif.ChangedFlagsMap, bool) { - profile, found := cfg.Profiles[name] - - return profile, found -} - -func (cfg MsSchemesConfig) Validate(name string, profiles ProfilesConfig) error { - if name == "" { - return nil - } - - var ( - found bool - scheme MsSchemeConfig - ) - - if scheme, found = cfg[name]; !found { - return fmt.Errorf("scheme: '%v' not found in config", name) - } - - for _, p := range scheme.Profiles { - if _, found := profiles.Profile(p); !found { - return fmt.Errorf("profile(referenced by scheme: '%v'): '%v' not found in config", - name, p, - ) - } - } - - return nil -} - -func (cfg MsSchemesConfig) Scheme(name string) (MsSchemeConfig, bool) { - config, found := cfg[name] - - return config, found -} - -type MsSamplerConfig struct { - Files uint `mapstructure:"files"` - Folders uint `mapstructure:"folders"` -} - -func (cfg *MsSamplerConfig) NoFiles() uint { - return cfg.Files -} - -func (cfg *MsSamplerConfig) NoFolders() uint { - return cfg.Folders -} - -type MsLabelsConfig struct { - Adhoc string `mapstructure:"adhoc"` - Journal string `mapstructure:"journal-suffix"` - Legacy string `mapstructure:"legacy"` - Trash string `mapstructure:"trash"` -} - -type MsAdvancedConfig struct { - Abort bool `mapstructure:"abort-on-error"` - Timeout string `mapstructure:"program-timeout"` - NoProgramRetries uint `mapstructure:"no-program-retries"` - Labels MsLabelsConfig `mapstructure:"labels"` -} - -func (cfg *MsAdvancedConfig) AbortOnError() bool { - return cfg.Abort -} - -func (cfg *MsAdvancedConfig) ProgramTimeout() (duration time.Duration, err error) { - return time.ParseDuration(cfg.Timeout) -} - -func (cfg *MsAdvancedConfig) NoRetries() uint { - return cfg.NoProgramRetries -} - -func (cfg *MsAdvancedConfig) AdhocLabel() string { - return cfg.Labels.Adhoc -} - -func (cfg *MsAdvancedConfig) JournalLabel() string { - return cfg.Labels.Journal -} - -func (cfg *MsAdvancedConfig) LegacyLabel() string { - return cfg.Labels.Legacy -} - -func (cfg *MsAdvancedConfig) TrashLabel() string { - return cfg.Labels.Trash -} diff --git a/src/app/proxy/controller-sampler_test.go b/src/app/proxy/controller-sampler_test.go index db5343e..9158608 100644 --- a/src/app/proxy/controller-sampler_test.go +++ b/src/app/proxy/controller-sampler_test.go @@ -10,7 +10,6 @@ import ( cmocks "github.com/snivilised/cobrass/src/assistant/mocks" "github.com/snivilised/extendio/xfs/storage" "github.com/snivilised/pixa/src/app/command" - "github.com/snivilised/pixa/src/app/proxy" "github.com/snivilised/pixa/src/app/mocks" "github.com/snivilised/pixa/src/internal/helpers" @@ -22,14 +21,6 @@ const ( BackyardWorldsPlanet9Scan01 = "nasa/exo/Backyard Worlds - Planet 9/sessions/scan-01" ) -var ( - _ proxy.ProfilesConfig = proxy.MsProfilesConfig{} - _ proxy.SamplerConfig = &proxy.MsSamplerConfig{} - _ proxy.ProfilesConfigReader = &command.MsProfilesConfigReader{} - _ proxy.SamplerConfigReader = &command.MsSamplerConfigReader{} - _ proxy.AdvancedConfigReader = &command.MsAdvancedConfigReader{} -) - type controllerTE struct { given string should string diff --git a/src/app/proxy/controller.go b/src/app/proxy/controller.go index 7b8d71b..80deb0b 100644 --- a/src/app/proxy/controller.go +++ b/src/app/proxy/controller.go @@ -67,9 +67,9 @@ func (c *controller) schemeSequence( ) Sequence { changed := c.shared.Inputs.ParamSet.Native.ThirdPartySet.LongChangedCL schemeCfg, _ := c.shared.schemes.Scheme(pi.scheme) // scheme already validated - sequence := make(Sequence, 0, len(schemeCfg.Profiles)) + sequence := make(Sequence, 0, len(schemeCfg.Profiles())) - for _, current := range schemeCfg.Profiles { + for _, current := range schemeCfg.Profiles() { cl := c.composeProfileCL(current, changed) step := &executionStep{ shared: c.shared, diff --git a/src/app/proxy/enter-shrink.go b/src/app/proxy/enter-shrink.go index 654185e..d6929d1 100644 --- a/src/app/proxy/enter-shrink.go +++ b/src/app/proxy/enter-shrink.go @@ -161,7 +161,7 @@ func (e *ShrinkEntry) createFinder() *PathFinder { if finder.Scheme != "" { schemeCFG, _ := e.SchemesCFG.Scheme(finder.Scheme) - finder.arity = len(schemeCFG.Profiles) + finder.arity = len(schemeCFG.Profiles()) } if e.Inputs.ParamSet.Native.OutputPath != "" { diff --git a/src/internal/helpers/mock-config-data.go b/src/internal/helpers/mock-config-data.go index 404e435..bdcc2cf 100644 --- a/src/internal/helpers/mock-config-data.go +++ b/src/internal/helpers/mock-config-data.go @@ -1,10 +1,16 @@ package helpers import ( + "fmt" + "time" + "github.com/snivilised/cobrass/src/clif" "github.com/snivilised/pixa/src/app/proxy" ) +// need to re-think this mock data as this is currently sub-optimal +// because of the unintended duplication of functionality + const ( noSampleFiles = 2 noSampleFolders = 1 @@ -19,11 +25,122 @@ var ( BackyardWorldsPlanet9Scan01Last4 []string ProfilesConfigData proxy.ProfilesConfigMap - SchemesConfigData *proxy.MsSchemesConfig - SamplerConfigData *proxy.MsSamplerConfig - AdvancedConfigData *proxy.MsAdvancedConfig + SchemesConfigData proxy.SchemesConfig + SamplerConfigData proxy.SamplerConfig + AdvancedConfigData proxy.AdvancedConfig +) + +type testProfilesConfig struct { + profiles proxy.ProfilesConfigMap +} + +func (cfg testProfilesConfig) Profile(name string) (clif.ChangedFlagsMap, bool) { + profile, found := cfg.profiles[name] + + return profile, found +} + +type ( + testSchemes map[string]proxy.SchemeConfig + testSchemesConfig struct { + schemes testSchemes + } + + testSchemeConfig struct { + profiles []string + } ) +func (cfg *testSchemeConfig) Profiles() []string { + return cfg.profiles +} + +func (cfg *testSchemesConfig) Validate(name string, profiles proxy.ProfilesConfig) error { + if name == "" { + return nil + } + + var ( + found bool + scheme proxy.SchemeConfig + ) + + if scheme, found = cfg.schemes[name]; !found { + return fmt.Errorf("scheme: '%v' not found in config", name) + } + + for _, p := range scheme.Profiles() { + if _, found := profiles.Profile(p); !found { + return fmt.Errorf("profile(referenced by scheme: '%v'): '%v' not found in config", + name, p, + ) + } + } + + return nil +} + +func (cfg *testSchemesConfig) Scheme(name string) (proxy.SchemeConfig, bool) { + config, found := cfg.schemes[name] + + return config, found +} + +type testSamplerConfig struct { + Files uint + Folders uint +} + +func (cfg *testSamplerConfig) NoFiles() uint { + return cfg.Files +} + +func (cfg *testSamplerConfig) NoFolders() uint { + return cfg.Folders +} + +type testLabelsConfig struct { + Adhoc string + Journal string + Legacy string + Trash string +} + +type testAdvancedConfig struct { + Abort bool + Timeout string + NoProgramRetries uint + Labels testLabelsConfig +} + +func (cfg *testAdvancedConfig) AbortOnError() bool { + return cfg.Abort +} + +func (cfg *testAdvancedConfig) ProgramTimeout() (duration time.Duration, err error) { + return time.ParseDuration(cfg.Timeout) +} + +func (cfg *testAdvancedConfig) NoRetries() uint { + return cfg.NoProgramRetries +} + +func (cfg *testAdvancedConfig) AdhocLabel() string { + return cfg.Labels.Adhoc +} + +func (cfg *testAdvancedConfig) JournalLabel() string { + return cfg.Labels.Journal +} + +func (cfg *testAdvancedConfig) LegacyLabel() string { + return cfg.Labels.Legacy +} + +func (cfg *testAdvancedConfig) TrashLabel() string { + return cfg.Labels.Trash +} + func init() { BackyardWorldsPlanet9Scan01First2 = []string{ "01_Backyard-Worlds-Planet-9_s01.jpg", @@ -75,31 +192,33 @@ func init() { }, } - SchemesConfigData = &proxy.MsSchemesConfig{ - "blur-sf": proxy.MsSchemeConfig{ - Profiles: []string{"blur", "sf"}, - }, - "adaptive-sf": proxy.MsSchemeConfig{ - Profiles: []string{"adaptive", "sf"}, - }, - "adaptive-blur": proxy.MsSchemeConfig{ - Profiles: []string{"adaptive", "blur"}, - }, - "singleton": proxy.MsSchemeConfig{ - Profiles: []string{"adaptive"}, + SchemesConfigData = &testSchemesConfig{ + schemes: testSchemes{ + "blur-sf": &testSchemeConfig{ + profiles: []string{"blur", "sf"}, + }, + "adaptive-sf": &testSchemeConfig{ + profiles: []string{"adaptive", "sf"}, + }, + "adaptive-blur": &testSchemeConfig{ + profiles: []string{"adaptive", "blur"}, + }, + "singleton": &testSchemeConfig{ + profiles: []string{"adaptive"}, + }, }, } - SamplerConfigData = &proxy.MsSamplerConfig{ + SamplerConfigData = &testSamplerConfig{ Files: noSampleFiles, Folders: noSampleFolders, } - AdvancedConfigData = &proxy.MsAdvancedConfig{ + AdvancedConfigData = &testAdvancedConfig{ Abort: false, Timeout: "10s", NoProgramRetries: noRetries, - Labels: proxy.MsLabelsConfig{ + Labels: testLabelsConfig{ Adhoc: "ADHOC", Journal: ".journal.txt", Legacy: ".LEGACY", diff --git a/src/internal/helpers/test-utils.go b/src/internal/helpers/test-utils.go index 2733e19..530ef46 100644 --- a/src/internal/helpers/test-utils.go +++ b/src/internal/helpers/test-utils.go @@ -194,8 +194,8 @@ func DoMockProfilesConfigsWith( ) { reader.EXPECT().Read(config).DoAndReturn( func(viper configuration.ViperConfig) (proxy.ProfilesConfig, error) { - stub := &proxy.MsProfilesConfig{ - Profiles: data, + stub := &testProfilesConfig{ + profiles: data, } return stub, nil @@ -204,7 +204,7 @@ func DoMockProfilesConfigsWith( } func DoMockSchemesConfigWith( - data *proxy.MsSchemesConfig, + data proxy.SchemesConfig, config configuration.ViperConfig, reader *mocks.MockSchemesConfigReader, ) { @@ -218,7 +218,7 @@ func DoMockSchemesConfigWith( } func DoMockSamplerConfigWith( - data *proxy.MsSamplerConfig, + data proxy.SamplerConfig, config configuration.ViperConfig, reader *mocks.MockSamplerConfigReader, ) { @@ -232,7 +232,7 @@ func DoMockSamplerConfigWith( } func DoMockAdvancedConfigWith( - data *proxy.MsAdvancedConfig, + data proxy.AdvancedConfig, config configuration.ViperConfig, reader *mocks.MockAdvancedConfigReader, ) {