* Support multiple loadpoints * Finalize loadpoint site split * Simplify global voltage * Fix push template error stopping main process * Show only last error on retry * Improve influx v1 compatibility * Update push templates * Revert influx v1 user change
33 lines
520 B
Go
33 lines
520 B
Go
package server
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestEncode(t *testing.T) {
|
|
tc := []struct {
|
|
in, out interface{}
|
|
}{
|
|
{int64(1), "1"},
|
|
{float64(1.2345), "1.234"},
|
|
{"1.2345", "\"1.2345\""},
|
|
{time.Duration(time.Hour), "3600"},
|
|
{"minpv", "\"minpv\""},
|
|
}
|
|
|
|
for _, tc := range tc {
|
|
t.Logf("%+v", tc)
|
|
out, err := encode(tc.in)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if out != tc.out {
|
|
t.Errorf("expected %v (string), got %v (%s)",
|
|
tc.out, out, reflect.TypeOf(out).Kind(),
|
|
)
|
|
}
|
|
}
|
|
}
|