Skip to content

Commit

Permalink
Fix gaussian test to properly test and graph non default repeat (#137)
Browse files Browse the repository at this point in the history
Gaussian test now properly uses repeat parameter to run and graph output data.
Fix lint issue
  • Loading branch information
carl-stlaurent-form3 authored Oct 4, 2023
1 parent 52025dc commit 9abbe66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/trigger/gaussian/gaussian_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func CalculateGaussianRate(volume, jitter float64, repeat, frequency, peak, stdd
if s == "" {
continue
}
weight, err := strconv.ParseFloat(s, 10)
weight, err := strconv.ParseFloat(s, 64)
if err != nil {
return nil, fmt.Errorf("unable to parse weights")
}
Expand Down
13 changes: 10 additions & 3 deletions internal/trigger/gaussian/gaussian_rate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,19 @@ func TestTotalVolumes(t *testing.T) {
volume: 100000,
repeat: 2 * time.Hour,
},
{
peak: 5 * time.Minute,
stddev: 75 * time.Second,
frequency: 1 * time.Second,
volume: 23499,
repeat: 1 * time.Hour,
},
} {
t.Run(fmt.Sprintf("%d: %f every %s, stddev: %s, peak: %s, jitter %f", i, test.volume, test.frequency.String(), test.stddev, test.peak, test.jitter), func(t *testing.T) {
c := NewGaussianRateCalculator(test.peak, test.stddev, test.frequency, test.weights, test.volume, 24*time.Hour)
c := NewGaussianRateCalculator(test.peak, test.stddev, test.frequency, test.weights, test.volume, test.repeat)
total := 0.0
current := time.Now().Truncate(24 * time.Hour)
end := current.Add(24 * time.Hour)
current := time.Now().Truncate(test.repeat)
end := current.Add(test.repeat)

calculate := api.WithJitter(c.For, test.jitter)
var rates []float64
Expand Down

0 comments on commit 9abbe66

Please sign in to comment.