Skip to content

Commit f57a27f

Browse files
Add comments
1 parent e6a814b commit f57a27f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎cmd/localstack/custom_interop_test.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func TestInvokeRequestContract(t *testing.T) {
4444
assert.Empty(t, req.ClientContext)
4545
}
4646

47+
// TestInvokeRequestClientContextContract checks that JSON encoding preserves the base64
48+
// context verbatim and omits an empty context. Decoding belongs to the invocation handler.
4749
func TestInvokeRequestClientContextContract(t *testing.T) {
4850
raw := `{"client-context":"eyJjdXN0b20iOnsiZm9vIjoiYmFyIn19"}`
4951
var req lsapi.InvokeRequest
@@ -57,6 +59,8 @@ func TestInvokeRequestClientContextContract(t *testing.T) {
5759
assert.NotContains(t, string(encoded), "client-context")
5860
}
5961

62+
// TestInvokeHandlerForwardsContextPerRequest reuses one handler across successive requests
63+
// to check decoding, context isolation, and preservation of the remaining invocation fields.
6064
func TestInvokeHandlerForwardsContextPerRequest(t *testing.T) {
6165
dispatched := make(chan *interop.Invoke, 1)
6266
handler := newInvokeHandler(func(invoke *interop.Invoke) { dispatched <- invoke })
@@ -67,8 +71,10 @@ func TestInvokeHandlerForwardsContextPerRequest(t *testing.T) {
6771
}{
6872
{"full", `{"custom":{"foo":"bar"},"client":{"app_title":"test"},"env":{"platform":"test"}}`, true},
6973
{"nested", `{"custom":{"nested":[1,true,null],"unicode":"\u00e9"}}`, true},
74+
// Neither form of an absent context may inherit the preceding request's value.
7075
{"omitted", "", false},
7176
{"empty", "", true},
77+
// Base64-looking data inside the decoded JSON must remain untouched.
7278
{"decoded-once", `"eyJmb28iOiJiYXIifQ=="`, true},
7379
}
7480
for _, test := range contexts {
@@ -111,6 +117,8 @@ func (failedInvocationBody) Read([]byte) (int, error) {
111117
return 0, errors.New("body read failed")
112118
}
113119

120+
// TestInvokeHandlerRejectsInvalidRequests checks that bad input gets HTTP 400 and unreadable
121+
// bodies get HTTP 500, with neither case starting a Lambda invocation in the background.
114122
func TestInvokeHandlerRejectsInvalidRequests(t *testing.T) {
115123
for _, test := range []struct {
116124
name string
@@ -139,6 +147,8 @@ func TestInvokeHandlerRejectsInvalidRequests(t *testing.T) {
139147
}
140148
}
141149

150+
// TestInvokeHandlerAcknowledgesBeforeCompletion holds the invocation open while checking
151+
// that /invoke returns 200 OK. Execution results are delivered later through callbacks.
142152
func TestInvokeHandlerAcknowledgesBeforeCompletion(t *testing.T) {
143153
release := make(chan struct{})
144154
completed := make(chan struct{})

0 commit comments

Comments
 (0)