Files
opencloud/pkg/jmap/jmap_tools_test.go
Pascal Bleser ae9c8dc653 groupware: feature test improvements and upgrade to Stalwart 0.14.1
* upgrade Stalwart image for devtools/full to 0.14.1

 * re-assert which features are implemented or not in 0.14.1

 * refactor the integration tests yet again to make it clearer and
   easier to see those "features-or-not"

 * get rid of old tests that are now better covered by integration tests

 * rewrite how we compare expected and actual objects in integration
   tests, finally having found a way to ignore the @type attribute
   properly instead of having to mutate all objects to remove it
2025-12-09 09:15:39 +01:00

25 lines
833 B
Go

package jmap
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/require"
)
func TestUnmarshallingError(t *testing.T) {
require := require.New(t)
responseBody := `{"methodResponses":[["error",{"type":"forbidden","description":"You do not have access to account a"},"a:0"]],"sessionState":"3e25b2a0"}`
var response Response
err := json.Unmarshal([]byte(responseBody), &response)
require.NoError(err)
require.Len(response.MethodResponses, 1)
require.Equal(ErrorCommand, response.MethodResponses[0].Command)
require.Equal("a:0", response.MethodResponses[0].Tag)
require.IsType(ErrorResponse{}, response.MethodResponses[0].Parameters)
er, _ := response.MethodResponses[0].Parameters.(ErrorResponse)
require.Equal("forbidden", er.Type)
require.Equal("You do not have access to account a", er.Description)
}