-
Notifications
You must be signed in to change notification settings - Fork 2
/
item_test.go
65 lines (59 loc) · 1.19 KB
/
item_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package stac_test
import (
"encoding/json"
"testing"
"github.com/planetlabs/go-stac"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestItemMarshal(t *testing.T) {
item := &stac.Item{
Version: "1.0.0",
Id: "item-id",
Geometry: map[string]any{
"type": "Point",
"coordinates": []float64{0, 0},
},
Properties: map[string]any{
"test": "value",
},
Links: []*stac.Link{
{Href: "https://example.com/stac/item-id", Rel: "self"},
},
Assets: map[string]*stac.Asset{
"thumbnail": {
Title: "Thumbnail",
Href: "https://example.com/stac/item-id/thumb.png",
Type: "image/png",
},
},
}
data, err := json.Marshal(item)
require.Nil(t, err)
expected := `{
"type": "Feature",
"stac_version": "1.0.0",
"id": "item-id",
"geometry": {
"type": "Point",
"coordinates": [0, 0]
},
"properties": {
"test": "value"
},
"links": [
{
"rel": "self",
"href": "https://example.com/stac/item-id"
}
],
"assets": {
"thumbnail": {
"title": "Thumbnail",
"href": "https://example.com/stac/item-id/thumb.png",
"type": "image/png"
}
}
}`
assert.JSONEq(t, expected, string(data))
}