summaryrefslogtreecommitdiffstats
path: root/model/plugins_response_test.go
blob: 1aa3cbcd04db89dec905bd59135bf0b604d1a81d (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:   []*PluginInfo{{Manifest: *manifest}},
		Inactive: []*PluginInfo{},
	}

	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))
}