From c4913bfc88dd7eb2db6facd2d52fbffa56ecdfef Mon Sep 17 00:00:00 2001 From: Jens Erat Date: Tue, 1 Oct 2019 18:23:41 +0200 Subject: [PATCH] fluent-bit: edge case tests (#1096) --- cmd/fluent-bit/loki_test.go | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/cmd/fluent-bit/loki_test.go b/cmd/fluent-bit/loki_test.go index b34020168ed7..31f6ea30a445 100644 --- a/cmd/fluent-bit/loki_test.go +++ b/cmd/fluent-bit/loki_test.go @@ -198,6 +198,22 @@ func Test_labelMapping(t *testing.T) { mapping map[string]interface{} want model.LabelSet }{ + { + "empty record", + map[string]interface{}{}, + map[string]interface{}{}, + model.LabelSet{}, + }, + { + "empty subrecord", + map[string]interface{}{ + "kubernetes": map[interface{}]interface{}{ + "foo": []byte("buzz"), + }, + }, + map[string]interface{}{}, + model.LabelSet{}, + }, { "bytes string", map[string]interface{}{ @@ -216,6 +232,39 @@ func Test_labelMapping(t *testing.T) { }, model.LabelSet{"test": "buzz", "output": "stderr"}, }, + { + "numeric label", + map[string]interface{}{ + "kubernetes": map[interface{}]interface{}{ + "integer": 42, + "floating_point": 42.42, + }, + "stream": "stderr", + }, + map[string]interface{}{ + "kubernetes": map[string]interface{}{ + "integer": "integer", + "floating_point": "floating_point", + }, + "stream": "output", + "nope": "nope", + }, + model.LabelSet{"integer": "42", "floating_point": "42.42", "output": "stderr"}, + }, + { + "list label", + map[string]interface{}{ + "kubernetes": map[interface{}]interface{}{ + "integers": []int{42, 43}, + }, + }, + map[string]interface{}{ + "kubernetes": map[string]interface{}{ + "integers": "integers", + }, + }, + model.LabelSet{"integers": "[42 43]"}, + }, { "deep string", map[string]interface{}{