diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6536f4..d0e1519 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,8 @@ name: CI on: [push, pull_request] env: - GO_VERSION: '1.22' - STATIC_CHECK_VERSION: '2023.1.6' + GO_VERSION: '1.23' + STATIC_CHECK_VERSION: '2024.1.1' COUNT_LOC_DOCKER_IMAGE: 'aldanial/cloc:1.98' jobs: statistics: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7ad6a1..af6c847 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: description: 'Release id (tag name)' required: true env: - GO_VERSION: '1.22' + GO_VERSION: '1.23' jobs: create_release: name: Create release draft diff --git a/go.mod b/go.mod index e1b73ae..d79108a 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,15 @@ module github.com/jotaen/klog -go 1.22 +go 1.23 require ( - cloud.google.com/go v0.112.0 - github.com/alecthomas/kong v0.8.1 + cloud.google.com/go v0.115.1 + github.com/alecthomas/kong v0.9.0 github.com/jotaen/genie v0.0.1 github.com/jotaen/kong-completion v0.0.6 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/posener/complete v1.2.3 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 ) require ( diff --git a/go.sum b/go.sum index 7b3bd00..f3b982d 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ -cloud.google.com/go v0.112.0 h1:tpFCD7hpHFlQ8yPwT3x+QeXqc2T6+n6T+hmABHfDUSM= -cloud.google.com/go v0.112.0/go.mod h1:3jEEVwZ/MHU4djK5t5RHuKOA/GbLddgTdVubX1qnPD4= -github.com/alecthomas/assert/v2 v2.1.0 h1:tbredtNcQnoSd3QBhQWI7QZ3XHOVkw1Moklp2ojoH/0= -github.com/alecthomas/assert/v2 v2.1.0/go.mod h1:b/+1DI2Q6NckYi+3mXyH3wFb8qG37K/DuK80n7WefXA= -github.com/alecthomas/kong v0.8.1 h1:acZdn3m4lLRobeh3Zi2S2EpnXTd1mOL6U7xVml+vfkY= -github.com/alecthomas/kong v0.8.1/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U= -github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE= -github.com/alecthomas/repr v0.1.0/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= +cloud.google.com/go v0.115.1 h1:Jo0SM9cQnSkYfp44+v+NQXHpcHqlnRJk2qxh6yvxxxQ= +cloud.google.com/go v0.115.1/go.mod h1:DuujITeaufu3gL68/lOFIirVNJwQeyf5UXyi+Wbgknc= +github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU= +github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/kong v0.9.0 h1:G5diXxc85KvoV2f0ZRVuMsi45IrBgx9zDNGNj165aPA= +github.com/alecthomas/kong v0.9.0/go.mod h1:Y47y5gKfHp1hDc7CH7OeXgLIpp+Q2m1Ni0L5s3bI8Os= +github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= +github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -33,8 +33,8 @@ github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab h1:ZjX6I48eZSFetP github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab/go.mod h1:/PfPXh0EntGc3QAAyUaviy4S9tzy4Zp0e2ilq4voC6E= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/klog/app/cli/start.go b/klog/app/cli/start.go index d59b172..3a20581 100644 --- a/klog/app/cli/start.go +++ b/klog/app/cli/start.go @@ -10,9 +10,7 @@ import ( ) type Start struct { - SummaryText klog.EntrySummary `name:"summary" short:"s" placeholder:"TEXT" help:"Summary text for this entry."` - Resume bool `name:"resume" short:"R" help:"Take over summary of last entry (if applicable). If the target record is new or empty, it looks at the previous record."` - ResumeNth int `name:"resume-nth" short:"N" help:"Take over summary of nth entry. If INT is positive, it counts from the start (beginning with '1'); if negative, it counts from the end (beginning with '-1')"` + util.SummaryArgs util.AtDateAndTimeArgs util.NoStyleArgs util.WarnArgs @@ -22,6 +20,7 @@ type Start struct { func (opt *Start) Help() string { return ` This appends a new open-ended entry to the record. + By default, it uses the record at today’s date for the new entry, or creates a new record if there no record at today’s date. You can otherwise specify a date with '--date'. @@ -45,6 +44,7 @@ func (opt *Start) Run(ctx app.Context) app.Error { ctx.Config().DefaultShouldTotal.Unwrap(func(s klog.ShouldTotal) { additionalData.ShouldTotal = s }) + spy := PreviousRecordSpy{} return util.Reconcile(ctx, util.ReconcileOpts{OutputFileArgs: opt.OutputFileArgs, WarnArgs: opt.WarnArgs}, []reconciling.Creator{ @@ -63,74 +63,6 @@ func (opt *Start) Run(ctx app.Context) app.Error { ) } -func (opt *Start) Summary(currentRecord klog.Record, previousRecord klog.Record) (klog.EntrySummary, app.Error) { - // Check for conflicting flags. - if opt.SummaryText != nil && (opt.Resume || opt.ResumeNth != 0) { - return nil, app.NewErrorWithCode( - app.LOGICAL_ERROR, - "Conflicting flags: --summary and --resume cannot be used at the same time", - "", - nil, - ) - } - if opt.Resume && opt.ResumeNth != 0 { - return nil, app.NewError( - "Illegal flag combination", - "Cannot combine --resume and --resume-nth", - nil, - ) - } - - // Return summary flag, if specified. - if opt.SummaryText != nil { - return opt.SummaryText, nil - } - - // If --resume was specified: return summary of last entry from current record, if - // it has any entries. Otherwise, return summary of last entry from previous record, - // if exists. - if opt.Resume { - if e, ok := findNthEntry(currentRecord, -1); ok { - return e.Summary(), nil - } - if previousRecord != nil { - if e, ok := findNthEntry(previousRecord, -1); ok { - return e.Summary(), nil - } - } - return nil, nil - } - - // If --resume-nth was specified: return summary of nth-entry. In contrast to --resume, - // don’t fall back to previous record, as that would be unintuitive here. - if opt.ResumeNth != 0 { - if e, ok := findNthEntry(currentRecord, opt.ResumeNth); ok { - return e.Summary(), nil - } - return nil, app.NewError( - "No such entry", - "", - nil, - ) - } - - return nil, nil -} - -func findNthEntry(r klog.Record, nr int) (klog.Entry, bool) { - entriesCount := len(r.Entries()) - i := func() int { - if nr > 0 { - return nr - 1 - } - return entriesCount + nr - }() - if i < 0 || i > entriesCount-1 { - return klog.Entry{}, false - } - return r.Entries()[i], true -} - type PreviousRecordSpy struct { PreviousRecord klog.Record } diff --git a/klog/app/cli/start_test.go b/klog/app/cli/start_test.go index 4e30383..92228ee 100644 --- a/klog/app/cli/start_test.go +++ b/klog/app/cli/start_test.go @@ -111,7 +111,9 @@ func TestStartWithSummary(t *testing.T) { AtDateAndTimeArgs: util.AtDateAndTimeArgs{ AtDateArgs: util.AtDateArgs{Date: klog.Ɀ_Date_(1920, 2, 2)}, }, - SummaryText: klog.Ɀ_EntrySummary_("Started something"), + SummaryArgs: util.SummaryArgs{ + SummaryText: klog.Ɀ_EntrySummary_("Started something"), + }, }).Run) require.Nil(t, err) assert.Equal(t, ` @@ -267,7 +269,9 @@ func TestStartWithResume(t *testing.T) { t.Run("No previous entry, no previous record -> Empty entry summary", func(t *testing.T) { state, err := NewTestingContext()._SetRecords(`1623-12-13 `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - Resume: true, + SummaryArgs: util.SummaryArgs{ + Resume: true, + }, }).Run) require.Nil(t, err) assert.Equal(t, `1623-12-13 @@ -281,7 +285,9 @@ func TestStartWithResume(t *testing.T) { 14:00 - 15:00 Did something 10m Some activity `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - Resume: true, + SummaryArgs: util.SummaryArgs{ + Resume: true, + }, }).Run) require.Nil(t, err) assert.Equal(t, ` @@ -298,7 +304,9 @@ func TestStartWithResume(t *testing.T) { state, err := NewTestingContext()._SetRecords(` 1623-12-12 `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - Resume: true, + SummaryArgs: util.SummaryArgs{ + Resume: true, + }, }).Run) require.Nil(t, err) assert.Equal(t, ` @@ -313,7 +321,9 @@ func TestStartWithResume(t *testing.T) { state, err := NewTestingContext()._SetRecords(`1623-12-13 8:13 - 9:44 `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - Resume: true, + SummaryArgs: util.SummaryArgs{ + Resume: true, + }, }).Run) require.Nil(t, err) assert.Equal(t, `1623-12-13 @@ -326,7 +336,9 @@ func TestStartWithResume(t *testing.T) { state, err := NewTestingContext()._SetRecords(`1623-12-13 8:13 - 9:44 Work `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - Resume: true, + SummaryArgs: util.SummaryArgs{ + Resume: true, + }, }).Run) require.Nil(t, err) assert.Equal(t, `1623-12-13 @@ -340,7 +352,9 @@ func TestStartWithResume(t *testing.T) { 8:13 - 9:44 Work 9:51 - 11:22 More work `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - Resume: true, + SummaryArgs: util.SummaryArgs{ + Resume: true, + }, }).Run) require.Nil(t, err) assert.Equal(t, `1623-12-13 @@ -355,7 +369,9 @@ func TestStartWithResume(t *testing.T) { 8:13 - 9:44 Work `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - Resume: true, + SummaryArgs: util.SummaryArgs{ + Resume: true, + }, }).Run) require.Nil(t, err) assert.Equal(t, `1623-12-13 @@ -371,8 +387,10 @@ func TestStartWithResume(t *testing.T) { 8:13 - 9:44 Work `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - Resume: true, - SummaryText: klog.Ɀ_EntrySummary_("Test"), + SummaryArgs: util.SummaryArgs{ + Resume: true, + SummaryText: klog.Ɀ_EntrySummary_("Test"), + }, }).Run) require.Error(t, err) }) @@ -382,8 +400,10 @@ func TestStartWithResume(t *testing.T) { 8:13 - 9:44 Work `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - Resume: true, - ResumeNth: 1, + SummaryArgs: util.SummaryArgs{ + Resume: true, + ResumeNth: 1, + }, }).Run) require.Error(t, err) }) @@ -397,7 +417,9 @@ func TestStartWithResumeNth(t *testing.T) { 2h Bar 3h Asdf `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - ResumeNth: nth, + SummaryArgs: util.SummaryArgs{ + ResumeNth: nth, + }, }).Run) require.Nil(t, err) assert.Equal(t, `1623-12-13 @@ -416,7 +438,9 @@ func TestStartWithResumeNth(t *testing.T) { 2h Bar 3h Asdf `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - ResumeNth: nth, + SummaryArgs: util.SummaryArgs{ + ResumeNth: nth, + }, }).Run) require.Nil(t, err) assert.Equal(t, `1623-12-13 @@ -435,7 +459,9 @@ func TestStartWithResumeNth(t *testing.T) { 2h Bar 3h `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - ResumeNth: nth, + SummaryArgs: util.SummaryArgs{ + ResumeNth: nth, + }, }).Run) require.Nil(t, err) assert.Equal(t, `1623-12-13 @@ -454,7 +480,9 @@ func TestStartWithResumeNth(t *testing.T) { 2h Bar 3h Asdf `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - ResumeNth: nth, + SummaryArgs: util.SummaryArgs{ + ResumeNth: nth, + }, }).Run) require.Error(t, err) } @@ -468,7 +496,9 @@ func TestStartWithResumeNth(t *testing.T) { 1623-12-13 `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - ResumeNth: -1, + SummaryArgs: util.SummaryArgs{ + ResumeNth: -1, + }, }).Run) require.Error(t, err) }) @@ -478,8 +508,10 @@ func TestStartWithResumeNth(t *testing.T) { 8:13 - 9:44 Work `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - ResumeNth: 1, - SummaryText: klog.Ɀ_EntrySummary_("Test"), + SummaryArgs: util.SummaryArgs{ + ResumeNth: 1, + SummaryText: klog.Ɀ_EntrySummary_("Test"), + }, }).Run) require.Error(t, err) }) @@ -489,8 +521,10 @@ func TestStartWithResumeNth(t *testing.T) { 8:13 - 9:44 Work `)._SetNow(1623, 12, 13, 12, 49)._Run((&Start{ - Resume: true, - ResumeNth: 1, + SummaryArgs: util.SummaryArgs{ + Resume: true, + ResumeNth: 1, + }, }).Run) require.Error(t, err) }) diff --git a/klog/app/cli/switch.go b/klog/app/cli/switch.go index 0bc5dd2..b357e58 100644 --- a/klog/app/cli/switch.go +++ b/klog/app/cli/switch.go @@ -1,14 +1,13 @@ package cli import ( - "github.com/jotaen/klog/klog" "github.com/jotaen/klog/klog/app" "github.com/jotaen/klog/klog/app/cli/util" "github.com/jotaen/klog/klog/parser/reconciling" ) type Switch struct { - SummaryText klog.EntrySummary `name:"summary" short:"s" placeholder:"TEXT" help:"Summary text for the new entry."` + util.SummaryArgs util.AtDateAndTimeArgs util.NoStyleArgs util.WarnArgs @@ -19,6 +18,11 @@ func (opt *Switch) Help() string { return ` Closes a previously ongoing activity (i.e., open time range), and starts a new one. This is basically a convenience for doing 'klog stop' and 'klog start' – however, in contrast to issuing both commands separately, 'klog switch' guarantees that the end time of the previous activity will be the same as the start time for the new entry. + +By default, it uses the record at today’s date for the new entry. You can otherwise specify a date with '--date'. + +Unless the '--time' flag is specified, it defaults to the current time as start/stop time. +If you prefer your time to be rounded, you can use the '--round' flag. ` } @@ -40,7 +44,11 @@ func (opt *Switch) Run(ctx app.Context) app.Error { return reconciler.CloseOpenRange(time, opt.TimeFormat(ctx.Config()), nil) }, func(reconciler *reconciling.Reconciler) error { - return reconciler.StartOpenRange(time, opt.TimeFormat(ctx.Config()), opt.SummaryText) + summary, sErr := opt.Summary(reconciler.Record, nil) + if sErr != nil { + return sErr + } + return reconciler.StartOpenRange(time, opt.TimeFormat(ctx.Config()), summary) }, ) } diff --git a/klog/app/cli/switch_test.go b/klog/app/cli/switch_test.go index c201786..86bd6d3 100644 --- a/klog/app/cli/switch_test.go +++ b/klog/app/cli/switch_test.go @@ -38,7 +38,9 @@ Next day AtDateAndTimeArgs: util.AtDateAndTimeArgs{ AtDateArgs: util.AtDateArgs{Date: klog.Ɀ_Date_(1920, 2, 2)}, }, - SummaryText: klog.Ɀ_EntrySummary_("Start", "over"), + SummaryArgs: util.SummaryArgs{ + SummaryText: klog.Ɀ_EntrySummary_("Start", "over"), + }, }).Run) require.Nil(t, err) assert.Equal(t, ` @@ -53,6 +55,60 @@ Next day `, state.writtenFileContents) } +func TestSwitchWithResume(t *testing.T) { + state, err := NewTestingContext()._SetRecords(` +1920-02-03 + 8:00 - 9:00 First + 9:00 - ? Second +`)._SetNow(1920, 2, 3, 9, 31)._Run((&Switch{ + SummaryArgs: util.SummaryArgs{ + Resume: true, + }, + }).Run) + require.Nil(t, err) + assert.Equal(t, ` +1920-02-03 + 8:00 - 9:00 First + 9:00 - 9:31 Second + 9:31 - ? Second +`, state.writtenFileContents) +} + +func TestSwitchWithResumeNth(t *testing.T) { + state, err := NewTestingContext()._SetRecords(` +1920-02-03 + 8:00 - 9:00 First + 9:00 - ? Second +`)._SetNow(1920, 2, 3, 9, 31)._Run((&Switch{ + SummaryArgs: util.SummaryArgs{ + ResumeNth: 1, + }, + }).Run) + require.Nil(t, err) + assert.Equal(t, ` +1920-02-03 + 8:00 - 9:00 First + 9:00 - 9:31 Second + 9:31 - ? First +`, state.writtenFileContents) +} + +func TestSwitchCannotResumeAndSummary(t *testing.T) { + state, err := NewTestingContext()._SetRecords(` +1920-02-03 + 8:00 - 9:00 First + 9:00 - ? Second +`)._SetNow(1920, 2, 3, 9, 31)._Run((&Switch{ + SummaryArgs: util.SummaryArgs{ + Resume: true, + SummaryText: klog.Ɀ_EntrySummary_("Foo"), + }, + }).Run) + require.Error(t, err) + assert.Equal(t, "Manipulation failed", err.Error()) + assert.Equal(t, "", state.writtenFileContents) +} + func TestSwitchWithStyle(t *testing.T) { t.Run("Without any preference, detect from file.", func(t *testing.T) { state, err := NewTestingContext()._SetRecords(` diff --git a/klog/app/cli/util/args.go b/klog/app/cli/util/args.go index 6513df4..17ded81 100644 --- a/klog/app/cli/util/args.go +++ b/klog/app/cli/util/args.go @@ -315,3 +315,77 @@ func (args *DecimalArgs) Apply(ctx *app.Context) { }) } } + +type SummaryArgs struct { + SummaryText klog.EntrySummary `name:"summary" short:"s" placeholder:"TEXT" help:"Summary text for the new entry."` + Resume bool `name:"resume" short:"R" help:"Take over summary of last entry (if applicable)."` + ResumeNth int `name:"resume-nth" short:"N" help:"Take over summary of nth entry. If INT is positive, it counts from the start (beginning with '1'); if negative, it counts from the end (beginning with '-1')"` +} + +func (args *SummaryArgs) Summary(currentRecord klog.Record, previousRecord klog.Record) (klog.EntrySummary, app.Error) { + // Check for conflicting flags. + if args.SummaryText != nil && (args.Resume || args.ResumeNth != 0) { + return nil, app.NewErrorWithCode( + app.LOGICAL_ERROR, + "Conflicting flags: --summary and --resume cannot be used at the same time", + "", + nil, + ) + } + if args.Resume && args.ResumeNth != 0 { + return nil, app.NewError( + "Illegal flag combination", + "Cannot combine --resume and --resume-nth", + nil, + ) + } + + // Return summary flag, if specified. + if args.SummaryText != nil { + return args.SummaryText, nil + } + + // If --resume was specified: return summary of last entry from current record, if + // it has any entries. Otherwise, return summary of last entry from previous record, + // if exists. + if args.Resume { + if e, ok := findNthEntry(currentRecord, -1); ok { + return e.Summary(), nil + } + if previousRecord != nil { + if e, ok := findNthEntry(previousRecord, -1); ok { + return e.Summary(), nil + } + } + return nil, nil + } + + // If --resume-nth was specified: return summary of nth-entry. In contrast to --resume, + // don’t fall back to previous record, as that would be unintuitive here. + if args.ResumeNth != 0 { + if e, ok := findNthEntry(currentRecord, args.ResumeNth); ok { + return e.Summary(), nil + } + return nil, app.NewError( + "No such entry", + "", + nil, + ) + } + + return nil, nil +} + +func findNthEntry(r klog.Record, nr int) (klog.Entry, bool) { + entriesCount := len(r.Entries()) + i := func() int { + if nr > 0 { + return nr - 1 + } + return entriesCount + nr + }() + if i < 0 || i > entriesCount-1 { + return klog.Entry{}, false + } + return r.Entries()[i], true +} diff --git a/klog/app/config.go b/klog/app/config.go index e2e42b6..b8f7753 100644 --- a/klog/app/config.go +++ b/klog/app/config.go @@ -2,6 +2,7 @@ package app import ( "errors" + "sort" "strings" "github.com/jotaen/genie" @@ -351,6 +352,7 @@ var CONFIG_FILE_ENTRIES = []ConfigFileEntries[any]{ keys = append(keys, k) } } + sort.Strings(keys) result = strings.Join(keys, ", ") }) return result, c.NoWarnings.origin diff --git a/klog/app/config_test.go b/klog/app/config_test.go index 8689742..1db2fce 100644 --- a/klog/app/config_test.go +++ b/klog/app/config_test.go @@ -215,7 +215,7 @@ func TestNoWarningsParamFromConfigFile(t *testing.T) { dc["MORE_THAN_24H"] = true return dc }()}, - // Multiple values + // Multiple values (sorted alphabetically) {`no_warnings = MORE_THAN_24H, OVERLAPPING_RANGES`, func() service.DisabledCheckers { dc := service.NewDisabledCheckers() dc["MORE_THAN_24H"] = true @@ -267,7 +267,7 @@ default_rounding = 15m default_should_total = 8h! date_format = YYYY-MM-DD time_convention = 24h -no_warnings = OVERLAPPING_RANGES, MORE_THAN_24H +no_warnings = MORE_THAN_24H, OVERLAPPING_RANGES `} { cfg, _ := NewConfig( FromDeterminedValues{NumCpus: 1},