-
Notifications
You must be signed in to change notification settings - Fork 0
/
sobek_test.go
47 lines (34 loc) · 1.86 KB
/
sobek_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package aws
import (
"testing"
"github.com/aws/aws-sdk-go-v2/service/eventbridge"
"github.com/aws/aws-sdk-go-v2/service/eventbridge/types"
"github.com/stretchr/testify/require"
"go.k6.io/k6/js/modulestest"
)
func Test_fromSobekObject(t *testing.T) {
rt := modulestest.NewRuntime(t)
t.Run("NestedStructs(eventbridge.CreateConnectionInput)", func(t *testing.T) {
root := rt.VU.Runtime().NewObject()
createConnectionApiKeyAuthRequestParameters := rt.VU.Runtime().NewObject()
createConnectionApiKeyAuthRequestParameters.Set(pascalToSnake("ApiKeyName"), "randomApiKeyName")
createConnectionApiKeyAuthRequestParameters.Set(pascalToSnake("ApiKeyValue"), "randomApiKeyValue")
connectionBodyParameter := rt.VU.Runtime().NewObject()
connectionBodyParameter.Set(pascalToSnake("IsValueSecret"), true)
connectionBodyParameter.Set(pascalToSnake("Key"), "randomKey")
connectionBodyParameter.Set(pascalToSnake("Value"), "randomValue")
bodyParameters := rt.VU.Runtime().NewArray(connectionBodyParameter)
invocationHttpParameters := rt.VU.Runtime().NewObject()
invocationHttpParameters.Set(pascalToSnake("BodyParameters"), bodyParameters)
authParameters := rt.VU.Runtime().NewObject()
authParameters.Set(pascalToSnake("ApiKeyAuthParameters"), createConnectionApiKeyAuthRequestParameters)
authParameters.Set(pascalToSnake("InvocationHttpParameters"), invocationHttpParameters)
root.Set(pascalToSnake("AuthParameters"), authParameters)
root.Set(pascalToSnake("AuthorizationType"), "BASIC")
in := &eventbridge.CreateConnectionInput{}
require.NoError(t, fromSobekObject(rt.VU.Runtime(), root, in))
require.Equal(t, "randomApiKeyName", *in.AuthParameters.ApiKeyAuthParameters.ApiKeyName)
require.Equal(t, "randomKey", *in.AuthParameters.InvocationHttpParameters.BodyParameters[0].Key)
require.Equal(t, types.ConnectionAuthorizationTypeBasic, in.AuthorizationType)
})
}