本文整理匯總了Golang中github.com/GeoNet/weft/wefttest.L函數的典型用法代碼示例。如果您正苦於以下問題:Golang L函數的具體用法?Golang L怎麽用?Golang L使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了L函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestTagAll
// all tags as a protobuf
func TestTagAll(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/tag", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var tr mtrpb.TagResult
if err = proto.Unmarshal(b, &tr); err != nil {
t.Error(err)
}
if len(tr.Result) != 6 {
t.Errorf("expected 6 tags got %d", len(tr.Result))
}
if tr.Result[0].Tag != "DAGG" {
t.Errorf("expected DAGG as the first tag got %s", tr.Result[0].Tag)
}
}
示例2: TestDataCompletenessSummary
// protobuf of latency summary info.
func TestDataCompletenessSummary(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/data/completeness/summary", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var f mtrpb.DataCompletenessSummaryResult
if err = proto.Unmarshal(b, &f); err != nil {
t.Error(err)
}
if len(f.Result) != 1 {
t.Error("expected 1 result.")
}
d := f.Result[0]
if d.SiteID != "TAUP" {
t.Errorf("expected TAUP got %s", d.SiteID)
}
if d.TypeID != "completeness.gnss.1hz" {
t.Errorf("expected gnss.1hz got %s", d.TypeID)
}
if d.Seconds == 0 {
t.Error("unexpected zero seconds")
}
r.URL = "/data/completeness/summary?typeID=completeness.gnss.1hz"
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
f.Reset()
if err = proto.Unmarshal(b, &f); err != nil {
t.Error(err)
}
if len(f.Result) != 1 {
t.Errorf("expected 1 result got %d results", len(f.Result))
}
}
示例3: TestTag
// protobuf of field metrics and latencies for a single tag.
func TestTag(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/tag/TAUP", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var tr mtrpb.TagSearchResult
if err = proto.Unmarshal(b, &tr); err != nil {
t.Error(err)
}
if tr.FieldMetric == nil {
t.Error("Got nil FieldMetric")
}
if tr.DataLatency == nil {
t.Error("Got nil DataLatency")
}
if tr.FieldState == nil {
t.Error("Got nil FieldState")
}
if tr.DataCompleteness == nil {
t.Error("Got nil DataCompleteness")
}
if tr.FieldMetric[0].DeviceID != "gps-taupoairport" {
t.Errorf("expected deviceID gps-taupoairport got %s", tr.FieldMetric[0].DeviceID)
}
if tr.DataLatency[0].SiteID != "TAUP" {
t.Errorf("expected siteID TAUP got %s", tr.DataLatency[0].SiteID)
}
if tr.FieldState[0].DeviceID != "gps-taupoairport" {
t.Errorf("expected deviceID gps-taupoairport got %s", tr.FieldState[0].DeviceID)
}
if tr.DataCompleteness[0].SiteID != "TAUP" {
t.Errorf("expected siteID TAUP got %s", tr.DataCompleteness[0].SiteID)
}
}
示例4: TestFieldMetricsThreshold
// protobuf of field metric threshold info.
func TestFieldMetricsThreshold(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/field/metric/threshold", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var f mtrpb.FieldMetricThresholdResult
if err = proto.Unmarshal(b, &f); err != nil {
t.Error(err)
}
if f.Result == nil {
t.Error("got nil for /field/metric/threshold protobuf")
}
if len(f.Result) != 1 {
t.Error("expected 1 result.")
}
d := f.Result[0]
if d.DeviceID != "gps-taupoairport" {
t.Errorf("expected gps-taupoairport got %s", d.DeviceID)
}
if d.TypeID != "voltage" {
t.Errorf("expected voltage got %s", d.TypeID)
}
if d.Upper != 45000 {
t.Errorf("expected 45000 got %d", d.Upper)
}
if d.Lower != 12000 {
t.Errorf("expected 12000 got %d", d.Lower)
}
if d.Scale != 0.001 {
t.Errorf("expected 0.001 got %f", d.Scale)
}
}
示例5: TestDataSites
// protobuf of data sites.
func TestDataSites(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/data/site", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var f mtrpb.DataSiteResult
if err = proto.Unmarshal(b, &f); err != nil {
t.Error(err)
}
if f.Result == nil {
t.Error("got nil for /data/site protobuf")
}
if len(f.Result) != 2 {
t.Error("expected 2 results.")
}
var found bool
for _, v := range f.Result {
if v.SiteID == "TAUP" {
found = true
if v.Latitude != -38.74270 {
t.Errorf("Data site TAUP got expected latitude -38.74270 got %f", v.Latitude)
}
if v.Longitude != 176.08100 {
t.Errorf("Data site TAUP got expected longitude 176.08100 got %f", v.Longitude)
}
}
}
if !found {
t.Error("Didn't find site TAUP")
}
}
示例6: TestFieldState
// protobuf for /field/state endpoint
func TestFieldState(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/field/state", Accept: "application/x-protobuf"}
var b []byte
var err error
// get the protobuf data back
if b, err = r.Do(testServer.URL); err != nil {
t.Fatal(err)
}
var dtr mtrpb.FieldStateResult
if err = proto.Unmarshal(b, &dtr); err != nil {
t.Fatal(err)
}
if dtr.Result == nil {
t.Fatal("got nil for /field/state protobuf")
}
if len(dtr.Result) != 1 {
t.Fatalf("expected 1 result, got %d.", len(dtr.Result))
}
res := dtr.Result[0]
if res.DeviceID != "gps-taupoairport" {
t.Errorf("expected gps-taupoairport got %s", res.DeviceID)
}
if res.TypeID != "mains" {
t.Errorf("expected mains got %s", res.TypeID)
}
if res.Seconds != 1431639630 {
t.Errorf("expected 1431639630 got %d", res.Seconds)
}
if res.Value != true {
t.Errorf("expected true got %s", res.Value)
}
}
示例7: TestFieldDevice
// protobuf of /model/device endpoint
func TestFieldDevice(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/field/device", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var fdr mtrpb.FieldDeviceResult
if err = proto.Unmarshal(b, &fdr); err != nil {
t.Error(err)
}
// ftr.Result should be a slice of struct pointers
if fdr.Result == nil {
t.Error("got nil for /field/device protobuf")
}
if len(fdr.Result) != 1 {
t.Error("expected 1 result.")
}
d := fdr.Result[0]
if d.ModelID != "Trimble NetR9" {
t.Errorf("expected Trimble NetR9 got %s", d.ModelID)
}
if d.DeviceID != "gps-taupoairport" {
t.Errorf("expected gps-taupoairport got %s", d.DeviceID)
}
if d.Latitude != -38.7427 {
t.Errorf("expected -38.7427 got %s", d.Latitude)
}
if d.Longitude != 176.081 {
t.Errorf("expected 176.081 got %s", d.Longitude)
}
}
示例8: TestFieldStateTag
// protobuf for /field/state/tag endpoint
func TestFieldStateTag(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/field/state/tag", Method: "GET", Accept: "application/x-protobuf"}
var b []byte
var err error
// get the protobuf data back
if b, err = r.Do(testServer.URL); err != nil {
t.Fatal(err)
}
var tr mtrpb.FieldStateTagResult
if err = proto.Unmarshal(b, &tr); err != nil {
t.Fatal(err)
}
if tr.Result == nil {
t.Fatal("got nil for /field/state protobuf")
}
if len(tr.Result) != 1 {
t.Fatalf("expected 1 result, got %d.", len(tr.Result))
}
res := tr.Result[0]
if res.DeviceID != "gps-taupoairport" {
t.Errorf("expected gps-taupoairport got %s", res.DeviceID)
}
if res.TypeID != "mains" {
t.Errorf("expected mains got %s", res.TypeID)
}
if res.Tag != "TAUP" {
t.Errorf("expected TAUP got %s", res.Tag)
}
}
示例9: TestFieldMetricHistoryLog
// protobuf of metric history log info.
func TestFieldMetricHistoryLog(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/field/metric?deviceID=gps-taupoairport&typeID=voltage&resolution=minute", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var f mtrpb.FieldMetricResult
if err = proto.Unmarshal(b, &f); err != nil {
t.Error(err)
}
if f.DeviceID != "gps-taupoairport" {
t.Errorf("expected gps-taupoairport got %s", f.DeviceID)
}
if f.TypeID != "voltage" {
t.Errorf("expected voltage got %s", f.TypeID)
}
if f.Upper != 45000 {
t.Errorf("expected 45000 got %d", f.Upper)
}
if f.Lower != 12000 {
t.Errorf("expected 12000 got %d", f.Lower)
}
if f.Scale != 0.001 {
t.Errorf("expected 12000 got %f", f.Scale)
}
// Not testing number of latency log
}
示例10: TestDataLatencyHistoryLog
// protobuf of latency history log info.
func TestDataLatencyHistoryLog(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/data/latency?siteID=TAUP&typeID=latency.strong&resolution=minute", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var f mtrpb.DataLatencyResult
if err = proto.Unmarshal(b, &f); err != nil {
t.Error(err)
}
if f.SiteID != "TAUP" {
t.Errorf("expected TAUP got %s", f.SiteID)
}
if f.TypeID != "latency.strong" {
t.Errorf("expected latency.strong got %s", f.TypeID)
}
if f.Upper != 15000 {
t.Errorf("expected 15000 got %d", f.Upper)
}
if f.Lower != 12000 {
t.Errorf("expected 12000 got %d", f.Lower)
}
if f.Scale != 1.0 {
t.Errorf("expected 1.0 got %f", f.Scale)
}
// Not testing number of latency log
}
示例11: TestFieldType
// protobuf of /model/type endpoint
func TestFieldType(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/field/type", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var ftr mtrpb.FieldTypeResult
if err = proto.Unmarshal(b, &ftr); err != nil {
t.Error(err)
}
// ftr.Result should be a slice of struct pointers
if ftr.Result == nil {
t.Error("got nil for /field/type protobuf")
}
if len(ftr.Result) != 12 {
t.Error("expected 12 results.")
}
if ftr.Result[0].TypeID != "centre" {
t.Errorf("expected centre got %s", ftr.Result[0].TypeID)
}
if ftr.Result[0].Display != "mV" {
t.Errorf("expected mV got %s", ftr.Result[0].Display)
}
}
示例12: TestDataTypes
func TestDataTypes(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/data/type", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var dtr mtrpb.DataTypeResult
if err = proto.Unmarshal(b, &dtr); err != nil {
t.Error(err)
}
if dtr.Result == nil {
t.Error("got nil for /data/type protobuf")
}
if len(dtr.Result) != 5 {
t.Errorf("expected 5 results, got %d.", len(dtr.Result))
}
if dtr.Result[0].TypeID != "latency.files.gnss" {
t.Errorf("expected latency.files.gnss got %s", dtr.Result[0].TypeID)
}
if dtr.Result[0].Display != "ms" {
t.Errorf("expected ms got %s", dtr.Result[0].Display)
}
}
示例13: TestGeoJSONFormat
func TestGeoJSONFormat(t *testing.T) {
setup(t)
defer teardown()
r := wt.Request{
ID: wt.L(),
Accept: CONTENT_TYPE_GeoJSON,
Content: CONTENT_TYPE_GeoJSON,
URL: url_wfs + "&outputFormat=json&cql_filter=BBOX(origin_geom,163.60840,-49.18170,182.98828,-32.28713)+AND+origintime>='2000-01-01'+AND+origintime<'2015-01-01'",
}
b, err := r.Do(ts.URL)
if err != nil {
t.Error(err)
t.Error(string(b))
}
body := bytes.NewBuffer(b)
res, err := client.Post("http://geojsonlint.com/validate", "application/vnd.geo+json", body)
defer res.Body.Close()
if err != nil {
t.Errorf("Problem contacting geojsonlint for test %s", r.ID)
}
b, err = ioutil.ReadAll(res.Body)
if err != nil {
t.Errorf("Problem reading body from geojsonlint for test %s", r.ID)
}
var v valid
err = json.Unmarshal(b, &v)
if err != nil {
t.Errorf("Problem unmarshalling body from geojsonlint for test %s", r.ID)
}
if v.Status != "ok" {
t.Errorf("invalid geoJSON for test %s" + r.ID)
}
}
示例14: TestFieldModel
// protobuf of /field/model endpoint
func TestFieldModel(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/field/model", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var ftr mtrpb.FieldModelResult
if err = proto.Unmarshal(b, &ftr); err != nil {
t.Error(err)
}
// ftr.Result should be a slice of struct pointers
if ftr.Result == nil {
t.Error("got nil for /field/model protobuf")
}
if len(ftr.Result) != 1 {
t.Error("expected 1 result.")
}
m := ftr.Result[0]
if m.ModelID != "Trimble NetR9" {
t.Errorf("expected Trimble NetR9 got %s", m.ModelID)
}
}
示例15: TestAppIDs
// protobuf for /app endpoint
func TestAppIDs(t *testing.T) {
setup(t)
defer teardown()
// Load test data.
if err := routes.DoAllStatusOk(testServer.URL); err != nil {
t.Error(err)
}
r := wt.Request{ID: wt.L(), URL: "/app", Accept: "application/x-protobuf"}
var b []byte
var err error
if b, err = r.Do(testServer.URL); err != nil {
t.Error(err)
}
var dtr mtrpb.AppIDSummaryResult
if err = proto.Unmarshal(b, &dtr); err != nil {
t.Error(err)
}
if dtr.Result == nil {
t.Error("got nil for /app protobuf")
}
if len(dtr.Result) != 1 {
t.Errorf("expected 1 result, got %d.", len(dtr.Result))
}
if dtr.Result[0].ApplicationID != "test-app" {
t.Errorf("expected test-app got %s", dtr.Result[0].ApplicationID)
}
}