kaxil commented on code in PR #67315: URL: https://github.com/apache/airflow/pull/67315#discussion_r3307688314
########## go-sdk/pkg/execution/frames_test.go: ########## @@ -0,0 +1,232 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package execution + +import ( + "bytes" + "encoding/binary" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vmihailenco/msgpack/v5" +) + +func TestEncodeRequest(t *testing.T) { + body := map[string]any{ + "type": "GetVariable", + "key": "my_var", + } + + data, err := encodeRequest(42, body) + require.NoError(t, err) + + // Decode and verify structure. + dec := msgpack.NewDecoder(bytes.NewReader(data)) + arrLen, err := dec.DecodeArrayLen() + require.NoError(t, err) + assert.Equal(t, 2, arrLen, "request frame should be 2-element array") + + id, err := dec.DecodeInt64() + require.NoError(t, err) + assert.Equal(t, int64(42), id) + + var decodedBody map[string]any + err = dec.Decode(&decodedBody) + require.NoError(t, err) + assert.Equal(t, "GetVariable", decodedBody["type"]) + assert.Equal(t, "my_var", decodedBody["key"]) +} + +func TestWriteAndReadFrame(t *testing.T) { Review Comment: Small regression in test coverage from the `maxFrameSize` -> `MaxFrameSize` rename: `TestReadFrameRejectsOversizedPayload` was dropped along with the constant, and the new `writeFrame` oversize guard at `frames.go:71-77` (the fix for the previous review's `uint32` wrap concern) has no test either. Neither test needs a real 4 GiB allocation -- the deleted read-side test already used a fake length prefix in a `bytes.Buffer`, and the write-side guard can be exercised by lowering the cap via a small test seam (or asserting the error path with a payload size constant patched in tests). Worth restoring both as regression pins so a future refactor can't quietly drop the protection. Non-blocking -- the production guards exist, just untested. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
