mirror of
https://github.com/Oxalide/vsphere-influxdb-go.git
synced 2023-10-10 13:36:51 +02:00
32 lines
627 B
Go
32 lines
627 B
Go
|
package statement
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func TestTimestampTime(t *testing.T) {
|
||
|
tstp := newTestTimestamp()
|
||
|
function := tstp.Time("2016-01-01", 100, "s")
|
||
|
expected := int64(1451606400)
|
||
|
got := function()
|
||
|
if expected != got {
|
||
|
t.Errorf("expected: %v\ngot: %v\n", expected, got)
|
||
|
}
|
||
|
function = tstp.Time("now", 100, "ns")
|
||
|
expected = time.Now().UnixNano()
|
||
|
got = function()
|
||
|
if expected < got {
|
||
|
t.Errorf("expected: %v\ngot: %v\n", expected, got)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func newTestTimestamp() *Timestamp {
|
||
|
duration, _ := time.ParseDuration("10s")
|
||
|
return &Timestamp{
|
||
|
Count: 5001,
|
||
|
Duration: duration,
|
||
|
Jitter: false,
|
||
|
}
|
||
|
}
|