mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-07-13 09:02:09 -04:00
groupware: jmap: add a test for Invocation seriaization
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user