summaryrefslogtreecommitdiffstats
path: root/model/plugins_response_test.go
blob: 9129c68f76372c07c1014fd11187aeacc1e786cf (plain)
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
package model

import (
	"strings"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestPluginsResponseJson(t *testing.T) {
	manifest := &Manifest{
		Id: "theid",
		Backend: &ManifestBackend{
			Executable: "theexecutable",
		},
		Webapp: &ManifestWebapp{
			BundlePath: "thebundlepath",
		},
	}

	response := &PluginsResponse{
		Active:   []*Manifest{manifest},
		Inactive: []*Manifest{},
	}

	json := response.ToJson()
	newResponse := PluginsResponseFromJson(strings.NewReader(json))
	assert.Equal(t, newResponse, response)
	assert.Equal(t, newResponse.ToJson(), json)
	assert.Equal(t, PluginsResponseFromJson(strings.NewReader("junk")), (*PluginsResponse)(nil))
}