Skip to content

Commit

Permalink
Merge pull request #3 from solemnwarning/store-command-line
Browse files Browse the repository at this point in the history
Honor store given on command line.
  • Loading branch information
lesomnus committed Dec 25, 2023
2 parents aec6220 + c193cf6 commit 83359ac
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
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

0 comments on commit 83359ac

Please sign in to comment.