Debian Codegraph @

geo_point_test.go

raw
1 // Copyright 2012-present Oliver Eilhard. All rights reserved.
2 // Use of this source code is governed by a MIT-license.
3 // See http://olivere.mit-license.org/license.txt for details.
4
5 package elastic
6
7 import (
8 "encoding/json"
9 "testing"
10 )
11
12 func TestGeoPointSource(t *testing.T) {
13 pt := GeoPoint{Lat: 40, Lon: -70}
14
15 data, err := json.Marshal(pt.Source())
16 if err != nil {
17 t.Fatalf("marshaling to JSON failed: %v", err)
18 }
19 got := string(data)
20 expected := `{"lat":40,"lon":-70}`
21 if got != expected {
22 t.Errorf("expected\n%s\n,got:\n%s", expected, got)
23 }
24 }