2017-10-25 08:17:17 -04:00
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestPluginsResponseJson(t *testing.T) {
|
|
|
|
|
manifest := &Manifest{
|
|
|
|
|
Id: "theid",
|
2018-07-18 18:32:33 -04:00
|
|
|
Server: &ManifestServer{
|
2017-10-25 08:17:17 -04:00
|
|
|
Executable: "theexecutable",
|
|
|
|
|
},
|
|
|
|
|
Webapp: &ManifestWebapp{
|
|
|
|
|
BundlePath: "thebundlepath",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response := &PluginsResponse{
|
2017-11-30 14:55:44 -06:00
|
|
|
Active: []*PluginInfo{{Manifest: *manifest}},
|
|
|
|
|
Inactive: []*PluginInfo{},
|
2017-10-25 08:17:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
}
|