498b235461
Build and test / Build and test AMD64 Ubuntu 22.04 (push) Failing after 0s
Publish Builder / amazonlinux2023 (push) Failing after 1s
Build and test / UT for Go (push) Has been skipped
Publish KRTE Images / KRTE (push) Failing after 1s
Build and test / Integration Test (push) Has been skipped
Build and test / Upload Code Coverage (push) Has been skipped
Publish Builder / rockylinux9 (push) Failing after 1s
Publish Builder / ubuntu22.04 (push) Failing after 0s
Publish Builder / ubuntu24.04 (push) Failing after 0s
Publish Gpu Builder / publish-gpu-builder (push) Failing after 1s
Publish Test Images / PyTest (push) Failing after 0s
Build and test / UT for Cpp (push) Has been cancelled
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package message
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestClearReplicateHeader(t *testing.T) {
|
|
t.Run("nil_message", func(t *testing.T) {
|
|
result := ClearReplicateHeader(nil)
|
|
assert.Nil(t, result)
|
|
})
|
|
|
|
t.Run("message_without_replicate_header", func(t *testing.T) {
|
|
msg := NewMutableMessageBeforeAppend([]byte("payload"), map[string]string{"key": "val"})
|
|
assert.Nil(t, msg.ReplicateHeader())
|
|
|
|
result := ClearReplicateHeader(msg)
|
|
assert.NotNil(t, result)
|
|
assert.Nil(t, result.ReplicateHeader())
|
|
})
|
|
|
|
t.Run("message_with_replicate_header_property", func(t *testing.T) {
|
|
// Directly set the replicate header property to simulate a replicated message.
|
|
props := map[string]string{
|
|
messageReplicateMesssageHeader: "some-header-data",
|
|
}
|
|
msg := NewMutableMessageBeforeAppend([]byte("payload"), props)
|
|
|
|
// Property exists before clear.
|
|
_, exists := msg.Properties().Get(messageReplicateMesssageHeader)
|
|
assert.True(t, exists)
|
|
|
|
result := ClearReplicateHeader(msg)
|
|
assert.NotNil(t, result)
|
|
|
|
// Property removed after clear.
|
|
_, exists = result.Properties().Get(messageReplicateMesssageHeader)
|
|
assert.False(t, exists)
|
|
})
|
|
}
|