diff options
| author | Shulhan <ms@kilabit.info> | 2022-08-15 20:13:55 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-08-15 20:13:55 +0700 |
| commit | 8a6eaebb36c0761b21398e72d934c072ac67fa7f (patch) | |
| tree | 35150d19108888fb2c85b6d4743411121de4e493 /config_test.go | |
| parent | 2965b17ccc24abde2346c20ee1f9384ae6e12f20 (diff) | |
| download | haminer-8a6eaebb36c0761b21398e72d934c072ac67fa7f.tar.xz | |
all: add support for influxd API v2
This changes replace the "influxdb_api_write" with new section
`[forwarder "influxd"]`.
The section contains version, url, org, bucket, user, password, and
token.
The version field define the API version to be used when writing log
to Influxd.
Diffstat (limited to 'config_test.go')
| -rw-r--r-- | config_test.go | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/config_test.go b/config_test.go index 775743b..a836d86 100644 --- a/config_test.go +++ b/config_test.go @@ -36,9 +36,10 @@ func TestNewConfig(t *testing.T) { func TestLoad(t *testing.T) { type testCase struct { - exp *Config - desc string - in string + exp *Config + desc string + in string + expError string } var cases = []testCase{{ @@ -49,17 +50,20 @@ func TestLoad(t *testing.T) { ForwardInterval: defForwardInterval, }, }, { - desc: "With path not exist", - in: "testdata/notexist.conf", - exp: &Config{ - listenAddr: defListenAddr, - listenPort: defListenPort, - ForwardInterval: defForwardInterval, - }, + desc: `With path not exist`, + in: `testdata/notexist.conf`, + expError: `Load: open testdata/notexist.conf: no such file or directory`, }, { desc: "With path exist", in: "testdata/haminer.conf", exp: &Config{ + Influxd: InfluxdConfig{ + Version: `v2`, + Url: `http://127.0.0.1:8086`, + Org: `kilabit.info`, + Bucket: `haproxy`, + apiWrite: `http://127.0.0.1:8086/api/v2/write?bucket=haproxy&org=kilabit.info&precision=ns`, + }, Listen: `0.0.0.0:8080`, listenAddr: `0.0.0.0`, listenPort: 8080, @@ -72,7 +76,6 @@ func TestLoad(t *testing.T) { "host", "referrer", }, - InfluxAPIWrite: "http://127.0.0.1:8086/write", HttpUrl: []string{ `/[0-9]+-\w+-\w+-\w+-\w+-\w+ => /-`, `/\w+-\w+-\w+-\w+-\w+ => /-`, @@ -106,7 +109,8 @@ func TestLoad(t *testing.T) { got = NewConfig() err = got.Load(c.in) if err != nil { - t.Fatal(err) + test.Assert(t, `error`, c.expError, err.Error()) + continue } test.Assert(t, `Config`, c.exp, got) |
