-
Notifications
You must be signed in to change notification settings - Fork 2
/
collection_test.go
54 lines (48 loc) · 1.08 KB
/
collection_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
package stac_test
import (
"encoding/json"
"testing"
"github.com/planetlabs/go-stac"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCollectionMarshal(t *testing.T) {
collection := &stac.Collection{
Version: "1.0.0",
Id: "collection-id",
Description: "Test Collection",
License: "various",
Links: []*stac.Link{
{Href: "https://example.com/stac/collections/collection-id", Rel: "self", Type: "application/json"},
},
Extent: &stac.Extent{
Spatial: &stac.SpatialExtent{
Bbox: [][]float64{{-180, -90, 180, 90}},
},
},
}
data, err := json.Marshal(collection)
require.Nil(t, err)
expected := `{
"type": "Collection",
"id": "collection-id",
"description": "Test Collection",
"extent": {
"spatial": {
"bbox": [
[-180, -90, 180, 90]
]
}
},
"license": "various",
"links": [
{
"href": "https://example.com/stac/collections/collection-id",
"rel": "self",
"type": "application/json"
}
],
"stac_version": "1.0.0"
}`
assert.JSONEq(t, expected, string(data))
}