Skip to content

Commit

Permalink
cli: fitactivity fix remover (#400)
Browse files Browse the repository at this point in the history
* fix: combine remove on remove mesg nums

* chore: clean up remover test
  • Loading branch information
muktihari committed Sep 8, 2024
1 parent 11f158a commit a83e41a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cmd/fitactivity/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,12 @@ loop:
return fmt.Errorf("conceal: no distance is provided: %w", errBadArgument)
}

var removeMesgNums map[typedef.MesgNum]struct{}
removeMesgNums := make(map[typedef.MesgNum]struct{})
if subcommandProvided(subcommands, subcommandRemove) {
if countSelectedFlag(fs, flagNameRemoveUnknown, flagNameRemoveMesgNums, flagNameRemoveDevData) == 0 {
return fmt.Errorf("remove: argument is provided: %w", errBadArgument)
}
parts := strings.Split(removeNums, ",")
removeMesgNums := make(map[typedef.MesgNum]struct{})
for _, part := range parts {
u16, err := strconv.ParseUint(part, 10, 16)
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions cmd/fitactivity/remover/remover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ func TestRemove(t *testing.T) {
{Num: mesgnum.MfgRangeMin},
{Num: mesgnum.MfgRangeMax},
{Num: mesgnum.Record},
{Num: mesgnum.GpsMetadata},
{Num: mesgnum.Lap},
{Num: mesgnum.Record},
{Num: mesgnum.Session},
},
},
opts: []Option{WithRemoveMesgNums(map[typedef.MesgNum]struct{}{
mesgnum.Record: {},
mesgnum.Record: {},
mesgnum.GpsMetadata: {},
})},
expected: &proto.FIT{
Messages: []proto.Message{
Expand All @@ -62,7 +64,7 @@ func TestRemove(t *testing.T) {
},
},
{
name: "remove user-defined messages only",
name: "remove developer data only",
fit: &proto.FIT{
Messages: []proto.Message{
{Num: mesgnum.FileId},
Expand Down

0 comments on commit a83e41a

Please sign in to comment.