Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
44
plugins/parsers/binary/entry_test.go
Normal file
44
plugins/parsers/binary/entry_test.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package binary
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/influxdata/telegraf/internal"
|
||||
)
|
||||
|
||||
func TestEntryExtract(t *testing.T) {
|
||||
testdata := []byte{0x01, 0x02, 0x03, 0x04}
|
||||
|
||||
e := &Entry{Type: "uint64"}
|
||||
_, _, err := e.extract(testdata, 0)
|
||||
require.EqualError(t, err, `unexpected entry: &{ uint64 0 false [] <nil>}`)
|
||||
}
|
||||
|
||||
func TestEntryConvertType(t *testing.T) {
|
||||
testdata := []byte{0x01, 0x02, 0x03, 0x04}
|
||||
|
||||
e := &Entry{Type: "garbage"}
|
||||
_, err := e.convertType(testdata, internal.HostEndianness)
|
||||
require.EqualError(t, err, `cannot handle type "garbage"`)
|
||||
}
|
||||
|
||||
func TestEntryConvertTimeType(t *testing.T) {
|
||||
testdata := []byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09}
|
||||
|
||||
e := &Entry{Type: "unix_ns", location: time.UTC}
|
||||
_, err := e.convertTimeType(testdata, internal.HostEndianness)
|
||||
require.EqualError(t, err, `too many bytes 9 vs 8`)
|
||||
}
|
||||
|
||||
func TestConvertNumericType(t *testing.T) {
|
||||
testdata := []byte{0x01, 0x02, 0x03, 0x04}
|
||||
|
||||
_, err := convertNumericType(testdata, "garbage", internal.HostEndianness)
|
||||
require.EqualError(t, err, `cannot determine length for type "garbage"`)
|
||||
|
||||
_, err = convertNumericType(testdata, "uint8", internal.HostEndianness)
|
||||
require.EqualError(t, err, `too many bytes 4 vs 1`)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue