Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor store given on command line. #3

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Store:
return nil, fmt.Errorf("parse store config: %w", err)
}

conf.Store = store
conf_given.Store = store

default:
return nil, errors.New("expected only 1 positional argument")
Expand Down
34 changes: 34 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,40 @@ func TestParseArgs(t *testing.T) {
require.Equal(expected, conf)
})

t.Run("config on command line", func(t *testing.T) {
require := require.New(t)

expected := &main.AppConfig{
Host: "bar",
Port: 1234,

Store: &main.StoreConfig{
Kind: "files",
Path: "store-data-here",
Opts: map[string]string{},
},

NoColor: true,
LogJson: true,

ReadOnly: true,
WriteOnly: false,
}

conf, err := main.ParseArgs([]string{
"",
"-host", "bar",
"-port", "1234",
"-no-color",
"-log-json",
"-read-only",
"files:store-data-here",
})
require.NoError(err)
require.NotNil(conf)
require.Equal(expected, conf)
})

t.Run("read config from file", func(t *testing.T) {
require := require.New(t)

Expand Down
Loading