Skip to content

Commit cd90e90

Browse files
committed
refactor(log_assertion): use serializer for encoding record batches
1 parent c8df471 commit cd90e90

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

internal/assertions/log_assertion.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ import (
99
kafkaapi "github.com/codecrafters-io/kafka-tester/protocol/api"
1010
"github.com/codecrafters-io/kafka-tester/protocol/common"
1111
"github.com/codecrafters-io/kafka-tester/protocol/decoder"
12+
"github.com/codecrafters-io/kafka-tester/protocol/serializer"
1213
"github.com/codecrafters-io/tester-utils/logger"
1314
)
1415

1516
type TopicPartitionLogAssertion struct {
1617
topic string
1718
partition int32
18-
RecordBatches []kafkaapi.RecordBatch
19+
RecordBatches kafkaapi.RecordBatches
1920
}
2021

21-
func NewTopicPartitionLogAssertion(topic string, partition int32, recordBatches []kafkaapi.RecordBatch) TopicPartitionLogAssertion {
22+
func NewTopicPartitionLogAssertion(topic string, partition int32, recordBatches kafkaapi.RecordBatches) TopicPartitionLogAssertion {
2223
return TopicPartitionLogAssertion{
2324
topic: topic,
2425
partition: partition,
@@ -35,7 +36,7 @@ func (a TopicPartitionLogAssertion) Run(logger *logger.Logger) error {
3536
return fmt.Errorf("Failed to read log file %s: %w", logFilePath, err)
3637
}
3738

38-
expectedEncodedRecordBatches := encodeRecordBatches(a.RecordBatches)
39+
expectedEncodedRecordBatches := serializer.GetEncodedBytes(a.RecordBatches)
3940
if len(expectedEncodedRecordBatches) == 0 {
4041
panic("Codecrafters Internal Error: RecordBatches are empty")
4142
}

0 commit comments

Comments
 (0)