-
Notifications
You must be signed in to change notification settings - Fork 0
/
influx_test.go
47 lines (36 loc) · 1.12 KB
/
influx_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
46
47
package main
import (
"os"
"testing"
"github.com/nilsmagnus/grib/griblib"
)
func Test_tofluxpoints(t *testing.T) {
testFile, fileErr := os.Open("testdata/gfs.t00z.pgrb2.2p50.f003")
if fileErr != nil {
t.Fatalf("Error opening testfile %v", fileErr)
}
messages, gribErr := griblib.ReadMessages(testFile)
filtered := griblib.Filter(messages, griblib.Options{
Discipline: 0,
Category: 0,
GeoFilter: griblib.GeoFilter{
MinLong:7000000,
MaxLong:11000000,
MinLat: 57000000,
MaxLat: 71000000},
})
if gribErr != nil {
t.Fatalf("Could not parse testfile, %v", gribErr)
}
fluxies := toInfluxPoints([]griblib.Message{filtered[0]}, 3)
if len(fluxies) == 0 || len(fluxies) != int(filtered[0].Section3.DataPointCount) {
t.Errorf("Expected fluxies length to be the same as message.datapointCount, expected %d, was %d",
messages[0].Section3.DataPointCount,
len(fluxies))
}
if len(fluxies) == 0 || len(fluxies) != len(filtered[0].Section7.Data) {
t.Errorf("Expected fluxies length to be the same as message.datapointCount, expected %d, was %d",
messages[0].Section3.DataPointCount,
len(fluxies))
}
}