mirror of
https://github.com/shouptech/tempgopher.git
synced 2026-02-03 08:39:43 +00:00
Allow configuration of InfluxDB address for tests
This commit is contained in:
parent
927f5b9043
commit
924473090e
2 changed files with 5 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ test:
|
||||||
variables:
|
variables:
|
||||||
GIN_MODE: debug
|
GIN_MODE: debug
|
||||||
INFLUXDB_DB: db
|
INFLUXDB_DB: db
|
||||||
|
INFLUXDB_ADDR: http://influxdb:8086
|
||||||
services:
|
services:
|
||||||
- influxdb
|
- influxdb
|
||||||
script:
|
script:
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_WriteStateToInflux(t *testing.T) {
|
func Test_WriteStateToInflux(t *testing.T) {
|
||||||
|
influxAddr := os.Getenv("INFLUXDB_ADDR")
|
||||||
state := State{Temp: 32}
|
state := State{Temp: 32}
|
||||||
|
|
||||||
// Test failure with empty config
|
// Test failure with empty config
|
||||||
|
|
@ -14,11 +16,11 @@ func Test_WriteStateToInflux(t *testing.T) {
|
||||||
assert.NotEqual(t, nil, err)
|
assert.NotEqual(t, nil, err)
|
||||||
|
|
||||||
// Test failure with missing database
|
// Test failure with missing database
|
||||||
err = WriteStateToInflux(state, Influx{Addr: "http://127.0.0.1:8086"})
|
err = WriteStateToInflux(state, Influx{Addr: influxAddr})
|
||||||
assert.NotEqual(t, nil, err)
|
assert.NotEqual(t, nil, err)
|
||||||
|
|
||||||
// Test success with writing to database
|
// Test success with writing to database
|
||||||
config := Influx{Addr: "http://127.0.0.1:8086", Database: "db"}
|
config := Influx{Addr: influxAddr, Database: "db"}
|
||||||
err = WriteStateToInflux(state, config)
|
err = WriteStateToInflux(state, config)
|
||||||
assert.Equal(t, nil, err)
|
assert.Equal(t, nil, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue