Skip to content

Commit

Permalink
edit example test
Browse files Browse the repository at this point in the history
  • Loading branch information
ketsiambaku committed Sep 9, 2024
1 parent 0c7f584 commit 00c22bd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions internal/common/debug/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ func (ati *activityTrackerImpl) Stats() Activities {
}{Info: a, Count: count})
}
}
slices.SortFunc(
activities,
func(a, b struct {
Info ActivityInfo
Count int64
}) int {
return cmp.Compare(strings.ToLower(a.Info.ActivityType), strings.ToLower(b.Info.ActivityType))
})
return activities
}

Expand Down Expand Up @@ -150,12 +142,22 @@ func Example() {

stopper1 = activityTracker.Start(info1)
stopper2 = activityTracker.Start(info2)
jsonActivities, _ := json.MarshalIndent(activityTracker.Stats(), "", " ")
sortFn := func(a, b struct {
Info ActivityInfo
Count int64
}) int {
return cmp.Compare(strings.ToLower(a.Info.ActivityType), strings.ToLower(b.Info.ActivityType))
}
activities := activityTracker.Stats()
slices.SortFunc(activities, sortFn)
jsonActivities, _ := json.MarshalIndent(activities, "", " ")
fmt.Println(string(jsonActivities))

stopper1.Stop()
stopper1.Stop()
jsonActivities, _ = json.MarshalIndent(activityTracker.Stats(), "", " ")
activities = activityTracker.Stats()
slices.SortFunc(activities, sortFn)
jsonActivities, _ = json.MarshalIndent(activities, "", " ")

fmt.Println(string(jsonActivities))
stopper2.Stop()
Expand Down

0 comments on commit 00c22bd

Please sign in to comment.