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:
|
||||
GIN_MODE: debug
|
||||
INFLUXDB_DB: db
|
||||
INFLUXDB_ADDR: http://influxdb:8086
|
||||
services:
|
||||
- influxdb
|
||||
script:
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_WriteStateToInflux(t *testing.T) {
|
||||
influxAddr := os.Getenv("INFLUXDB_ADDR")
|
||||
state := State{Temp: 32}
|
||||
|
||||
// Test failure with empty config
|
||||
|
|
@ -14,11 +16,11 @@ func Test_WriteStateToInflux(t *testing.T) {
|
|||
assert.NotEqual(t, nil, err)
|
||||
|
||||
// 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)
|
||||
|
||||
// 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)
|
||||
assert.Equal(t, nil, err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue