Skip to content

Commit

Permalink
Revert "edit example test"
Browse files Browse the repository at this point in the history
This reverts commit 00c22bd.
  • Loading branch information
ketsiambaku committed Sep 9, 2024
1 parent 00c22bd commit 273aa4b
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions internal/common/debug/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ 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 @@ -142,22 +150,12 @@ func Example() {

stopper1 = activityTracker.Start(info1)
stopper2 = activityTracker.Start(info2)
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, "", " ")
jsonActivities, _ := json.MarshalIndent(activityTracker.Stats(), "", " ")
fmt.Println(string(jsonActivities))

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

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

0 comments on commit 273aa4b

Please sign in to comment.