-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsquirrel_test.go
35 lines (33 loc) · 894 Bytes
/
squirrel_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main_test
import (
main "github.com/inktomi/squirrel"
"github.com/inktomi/squirrel/telemetry"
"testing"
"time"
)
func TestReportWeightIfNeeded(t *testing.T) {
type args struct {
lastReported int64
adafruitClient *telemetry.Adafruit
weight float64
}
tests := []struct {
name string
args args
wantErr bool
}{
{"Too Fast",
args{lastReported: time.Now().Unix(), adafruitClient: &telemetry.Adafruit{}, weight: 10},
true},
{"Correct Timing",
args{lastReported: time.Now().Unix() - 30, adafruitClient: &telemetry.Adafruit{}, weight: 10},
true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := main.ReportWeightIfNeeded(tt.args.lastReported, tt.args.adafruitClient, tt.args.weight); (err != nil) != tt.wantErr {
t.Errorf("ReportWeightIfNeeded() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}