forked from kumina/postfix_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
showq_test.go
45 lines (42 loc) · 1.08 KB
/
showq_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
36
37
38
39
40
41
42
43
44
45
package main
import (
"github.com/kumina/postfix_exporter/mock"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestCollectShowqFromReader(t *testing.T) {
type args struct {
file string
}
tests := []struct {
name string
args args
wantErr bool
expectedTotalCount float64
}{
{
name: "basic test",
args: args{
file: "testdata/showq.txt",
},
wantErr: false,
expectedTotalCount: 118702,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
file, err := os.Open(tt.args.file)
if err != nil {
t.Error(err)
}
sizeHistogram := mock.NewHistogramVecMock()
ageHistogram := mock.NewHistogramVecMock()
if err := CollectTextualShowqFromScanner(sizeHistogram, ageHistogram, file); (err != nil) != tt.wantErr {
t.Errorf("CollectShowqFromReader() error = %v, wantErr %v", err, tt.wantErr)
}
assert.Equal(t, tt.expectedTotalCount, sizeHistogram.GetSum(), "Expected a lot more data.")
assert.Less(t, 0.0, ageHistogram.GetSum(), "Age not greater than 0")
})
}
}