github.com/rajatvaryani/mattermost-server@v5.11.1+incompatible/model/plugins_response_test.go (about) 1 package model 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestPluginsResponseJson(t *testing.T) { 11 manifest := &Manifest{ 12 Id: "theid", 13 Server: &ManifestServer{ 14 Executable: "theexecutable", 15 }, 16 Webapp: &ManifestWebapp{ 17 BundlePath: "thebundlepath", 18 }, 19 } 20 21 response := &PluginsResponse{ 22 Active: []*PluginInfo{{Manifest: *manifest}}, 23 Inactive: []*PluginInfo{}, 24 } 25 26 json := response.ToJson() 27 newResponse := PluginsResponseFromJson(strings.NewReader(json)) 28 assert.Equal(t, newResponse, response) 29 assert.Equal(t, newResponse.ToJson(), json) 30 assert.Equal(t, PluginsResponseFromJson(strings.NewReader("junk")), (*PluginsResponse)(nil)) 31 }