groupware: jmap: add a test for Invocation seriaization

This commit is contained in:
Pascal Bleser
2026-06-10 13:49:12 +02:00
parent 7533369c63
commit 8fa045b5c0

View File

@@ -2,6 +2,9 @@ package jmap
import (
"encoding/json"
"fmt"
"math/rand"
"strconv"
"testing"
"github.com/stretchr/testify/require"
@@ -33,3 +36,12 @@ func TestSquashKeyedStates(t *testing.T) {
})
require.Equal("a:aaa,b:bbb,c:ccc", string(result))
}
func TestInvocationMarshalling(t *testing.T) {
tag := strconv.Itoa(1000 + rand.Intn(1000))
accountId := fmt.Sprintf("a%d", 100+rand.Intn(100))
inv := invocation(IdentityGetCommand{AccountId: AccountId(accountId), Ids: []string{"x", "y", "z"}}, tag)
b, err := json.Marshal(inv)
require.NoError(t, err)
require.Equal(t, fmt.Sprintf(`{"Command":"Identity/get","Parameters":{"accountId":"%s","ids":["x","y","z"]},"Tag":"%s"}`, accountId, tag), string(b))
}