...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package spec
16
17 import (
18 "encoding/json"
19 "testing"
20
21 "github.com/stretchr/testify/assert"
22 "github.com/stretchr/testify/require"
23 )
24
25 var license = License{
26 LicenseProps: LicenseProps{Name: "the name", URL: "the url"},
27 VendorExtensible: VendorExtensible{Extensions: map[string]interface{}{"x-license": "custom term"}}}
28
29 const licenseJSON = `{
30 "name": "the name",
31 "url": "the url",
32 "x-license": "custom term"
33 }`
34
35 func TestIntegrationLicense(t *testing.T) {
36
37
38
39 b, err := json.MarshalIndent(license, "", "\t")
40 require.NoError(t, err)
41 assert.Equal(t, licenseJSON, string(b))
42
43 actual := License{}
44 err = json.Unmarshal([]byte(licenseJSON), &actual)
45 require.NoError(t, err)
46 assert.EqualValues(t, license, actual)
47 }
48
View as plain text