chronograf/bolt/internal/internal_test.go

53 lines
1.3 KiB
Go
Raw Normal View History

package internal_test
import (
"reflect"
"testing"
"time"
"github.com/influxdata/mrfusion"
2016-09-28 19:32:58 +00:00
"github.com/influxdata/mrfusion/bolt/internal"
)
// Ensure an exploration can be marshaled and unmarshaled.
func TestMarshalExploration(t *testing.T) {
v := mrfusion.Exploration{
ID: 12,
Name: "Some Exploration",
UserID: 34,
Data: "{\"data\":\"something\"}",
CreatedAt: time.Now().UTC(),
UpdatedAt: time.Now().UTC(),
}
2016-09-28 19:32:58 +00:00
var vv mrfusion.Exploration
if buf, err := internal.MarshalExploration(&v); err != nil {
t.Fatal(err)
2016-09-28 19:32:58 +00:00
} else if err := internal.UnmarshalExploration(buf, &vv); err != nil {
t.Fatal(err)
2016-09-28 19:32:58 +00:00
} else if !reflect.DeepEqual(v, vv) {
t.Fatalf("exploration protobuf copy error: got %#v, expected %#v", vv, v)
}
}
func TestMarshalSource(t *testing.T) {
v := mrfusion.Source{
ID: 12,
Name: "Fountain of Truth",
Type: "influx",
Username: "docbrown",
Password: "1 point twenty-one g1g@w@tts",
URL: []string{"http://twin-pines.mall.io:8086", "https://lonepine.mall.io:8086"},
Default: true,
}
var vv mrfusion.Source
if buf, err := internal.MarshalSource(v); err != nil {
t.Fatal(err)
} else if err := internal.UnmarshalSource(buf, &vv); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(v, vv) {
t.Fatalf("source protobuf copy error: got %#v, expected %#v", vv, v)
}
}