Skip to content

Commit

Permalink
Testing\!
Browse files Browse the repository at this point in the history
  • Loading branch information
midnightconman committed May 7, 2021
1 parent 4af605c commit 434e1b8
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions pkg/tracing/lightstep/lightstep_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) The Thanos Authors.
// Licensed under the Apache License 2.0.

package lightstep

import (
"os"
"testing"

"github.com/thanos-io/thanos/pkg/testutil"

"github.com/opentracing/opentracing-go"
)

func TestParseTags(t *testing.T) {
type testData struct {
input string
description string
expectedOutput opentracing.Tags
}

testingData := []testData{
{
description: `A very simple case, key "foo" and value "bar"`,
input: "foo=bar",
expectedOutput: opentracing.Tags{"foo": "bar"},
},
{
description: `A simple case multiple keys, keys ["foo", "bar"] and values ["foo", "bar"]`,
input: "foo=foo,bar=bar",
expectedOutput: opentracing.Tags{"foo": "foo", "bar": "bar"},
},
{
description: `A case with empty environment variable, key "foo" and value ""`,
input: "foo=${TEST:}",
expectedOutput: opentracing.Tags{"foo": ""},
},
{
description: `A case with empty environment variable, key "foo" and value ""`,
input: "foo=${TEST:}",
expectedOutput: opentracing.Tags{"foo": ""},
},
{
description: `A case with default environment variable, key "foo" and value "default"`,
input: "foo=${TEST:default}",
expectedOutput: opentracing.Tags{"foo": "default"},
},
{
description: `A case with real environment variable, key "foo" and value "env-bar"`,
input: "foo=${_TEST_PARSE_TAGS:default}",
expectedOutput: opentracing.Tags{"foo": "env-bar"},
},
}

os.Setenv("_TEST_PARSE_TAGS", "env-bar")
for _, test := range testingData {
t.Logf("testing %s\n", test.description)
testutil.Equals(t, test.expectedOutput, parseTags(test.input))
}
}

0 comments on commit 434e1b8

Please sign in to comment.