Added unit tests for kafkaServer implementation#357
Added unit tests for kafkaServer implementation#357Yashwanth-Ranjan-Singaravel wants to merge 12 commits intoopen-lambda:mainfrom
Conversation
tylerharter
left a comment
There was a problem hiding this comment.
There are too many tests to review at once. Can we start with 1 or 2? Simple stuff, like there is one message, and make sure there is one invocation as a results.
Also, can we update the GitHub CI so the go unit tests will run?
go/worker/event/kafkaServer.go
Outdated
| // NewKafkaManager creates and configures a new Kafka manager | ||
| func NewKafkaManager(lambdaManager *lambda.LambdaMgr) (*KafkaManager, error) { | ||
| var invoker LambdaInvoker | ||
| if lambdaManager != nil { |
There was a problem hiding this comment.
Why do we have a nil check? Is it reasonable to get nil? We could just not check (like before), or just panic if nil.
go/worker/event/kafkaServer_test.go
Outdated
| "github.com/twmb/franz-go/pkg/kgo" | ||
| ) | ||
|
|
||
| // syncBuffer is a thread-safe bytes.Buffer for capturing logs from goroutines. |
There was a problem hiding this comment.
This is all very complicated for some tests, can we get some simpler tests in first, and discuss whether we need more before doing this?
| } | ||
|
|
||
| func TestConsumeLoop_ContinuesThroughErrors(t *testing.T) { | ||
| var logBuf bytes.Buffer |
There was a problem hiding this comment.
Let's have error count, or some other way to test that doesn't involve redirecting and capturing logs
|
|
||
| // runConsumeLoop starts the consume loop in a goroutine and returns a stop | ||
| // function that signals shutdown and waits for the goroutine to exit. | ||
| func runConsumeLoop(consumer *LambdaKafkaConsumer) (stop func()) { |
There was a problem hiding this comment.
more comments to walk through the logic here
| // --- Tests --- | ||
|
|
||
| func TestConsumeLoop_ProcessesRecords(t *testing.T) { | ||
| invoker := &MockLambdaInvoker{} |
There was a problem hiding this comment.
better comments. we're testing the consumer. above layer (client) is mocked, and below layer (invoker) is mocked.
No description provided.