From 3d91bcda464f6478de40db8d4e2d97da5e5af860 Mon Sep 17 00:00:00 2001 From: devops Date: Sun, 10 Oct 2021 05:47:14 +1000 Subject: [PATCH] Add unit test for with/without Kafka executor message key --- .../bins/dkron-executor-kafka/kafka_test.go | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/builtin/bins/dkron-executor-kafka/kafka_test.go b/builtin/bins/dkron-executor-kafka/kafka_test.go index 79b171f46..2c67a7851 100644 --- a/builtin/bins/dkron-executor-kafka/kafka_test.go +++ b/builtin/bins/dkron-executor-kafka/kafka_test.go @@ -7,12 +7,13 @@ import ( dktypes "github.com/distribworks/dkron/v3/plugin/types" ) -func TestProduceExecute(t *testing.T) { +func TestProduceExecuteWithKey(t *testing.T) { pa := &dktypes.ExecuteRequest{ - JobName: "testJob", + JobName: "testJobWithKey", Config: map[string]string{ "topic": "test", "brokerAddress": "testaddress", + "key": "testkey", "message": "{\"hello\":11}", "debug": "true", }, @@ -25,3 +26,22 @@ func TestProduceExecute(t *testing.T) { t.Fatal(err) } } + +func TestProduceExecuteWithoutKey(t *testing.T) { + pa := &dktypes.ExecuteRequest{ + JobName: "testJobWithoutKey", + Config: map[string]string{ + "topic": "test", + "brokerAddress": "testaddress", + "message": "{\"hello\":11}", + "debug": "true", + }, + } + kafka := &Kafka{} + output, err := kafka.Execute(pa, nil) + fmt.Println(string(output.Output)) + fmt.Println(err) + if err != nil { + t.Fatal(err) + } +} \ No newline at end of file