Skip to content

Commit 44692ab

Browse files
authored
Drop dependency on github.com/loadimpact/k6/stats/influxdb in tests as well (#3)
1 parent d507d01 commit 44692ab

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

pkg/kafka/collector_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ func TestRun(t *testing.T) {
5656

5757
func TestFormatSamples(t *testing.T) {
5858
c := Collector{}
59-
c.Config.InfluxDBConfig.ConcurrentWrites = null.IntFrom(10)
6059
metric := stats.New("my_metric", stats.Gauge)
6160
samples := stats.Samples{
6261
{Metric: metric, Value: 1.25, Tags: stats.IntoSampleTags(&map[string]string{"a": "1"})},

pkg/kafka/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ func ParseArg(arg string) (Config, error) {
9999
if err != nil {
100100
return c, err
101101
}
102-
c.InfluxDBConfig = influxConfig
102+
c.InfluxDBConfig = c.InfluxDBConfig.Apply(influxConfig)
103103
}
104+
104105
delete(params, "influxdb")
105106

106107
if v, ok := params["push_interval"].(string); ok {

pkg/kafka/config_test.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ import (
3131
"gopkg.in/guregu/null.v3"
3232

3333
"github.com/loadimpact/k6/lib/types"
34-
"github.com/loadimpact/k6/stats/influxdb"
3534
)
3635

3736
func TestConfigParseArg(t *testing.T) {
3837
c, err := ParseArg("brokers=broker1,topic=someTopic,format=influxdb")
39-
expInfluxConfig := influxdb.Config{}
38+
expInfluxConfig := influxdbConfig{}
4039
assert.Nil(t, err)
4140
assert.Equal(t, []string{"broker1"}, c.Brokers)
4241
assert.Equal(t, null.StringFrom("someTopic"), c.Topic)
@@ -50,7 +49,7 @@ func TestConfigParseArg(t *testing.T) {
5049
assert.Equal(t, null.StringFrom("json"), c.Format)
5150

5251
c, err = ParseArg("brokers={broker2,broker3:9092},topic=someTopic,format=influxdb,influxdb.tagsAsFields=fake")
53-
expInfluxConfig = influxdb.Config{
52+
expInfluxConfig = influxdbConfig{
5453
TagsAsFields: []string{"fake"},
5554
}
5655
assert.Nil(t, err)
@@ -60,7 +59,7 @@ func TestConfigParseArg(t *testing.T) {
6059
assert.Equal(t, expInfluxConfig, c.InfluxDBConfig)
6160

6261
c, err = ParseArg("brokers={broker2,broker3:9092},topic=someTopic,format=influxdb,influxdb.tagsAsFields={fake,anotherFake}")
63-
expInfluxConfig = influxdb.Config{
62+
expInfluxConfig = influxdbConfig{
6463
TagsAsFields: []string{"fake", "anotherFake"},
6564
}
6665
assert.Nil(t, err)
@@ -84,18 +83,7 @@ func TestConsolidatedConfig(t *testing.T) {
8483
config: Config{
8584
Format: null.StringFrom("json"),
8685
PushInterval: types.NullDurationFrom(1 * time.Second),
87-
InfluxDBConfig: influxdb.NewConfig(),
88-
},
89-
},
90-
"bad influxdb concurrent writes": {
91-
env: map[string]string{"K6_INFLUXDB_CONCURRENT_WRITES": "-2"},
92-
config: Config{
93-
Format: null.StringFrom("json"),
94-
PushInterval: types.NullDurationFrom(1 * time.Second),
95-
InfluxDBConfig: influxdb.NewConfig().Apply(
96-
influxdb.Config{
97-
ConcurrentWrites: null.IntFrom(-2),
98-
}),
86+
InfluxDBConfig: newInfluxdbConfig(),
9987
},
10088
},
10189
}

0 commit comments

Comments
 (0)