67 lines
1.1 KiB
Go
67 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func TestMeterConfig(t *testing.T) {
|
|
yaml := `
|
|
meters:
|
|
- name: pv
|
|
type: exec # mqtt will fail due to missing global
|
|
power: topic
|
|
- name: charge
|
|
type: exec
|
|
power: script
|
|
`
|
|
viper.SetConfigType("yaml")
|
|
if err := viper.ReadConfig(bytes.NewBuffer([]byte(yaml))); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
// var conf Config
|
|
// if err := viper.UnmarshalExact(&conf); err != nil {
|
|
// t.Error(err)
|
|
// }
|
|
|
|
// _ = configureMeters(conf)
|
|
}
|
|
func TestChargerConfig(t *testing.T) {
|
|
yaml := `
|
|
chargers:
|
|
- name: test
|
|
type: configurable
|
|
status:
|
|
type: script
|
|
cmd: script
|
|
actualCurrent:
|
|
type: script
|
|
cmd: script
|
|
enable:
|
|
type: script
|
|
cmd: script
|
|
enabled:
|
|
type: script
|
|
cmd: script
|
|
maxCurrent:
|
|
type: script
|
|
cmd: script
|
|
- name: wallbe
|
|
type: wallbe
|
|
uri: 192.168.0.8:502
|
|
`
|
|
viper.SetConfigType("yaml")
|
|
if err := viper.ReadConfig(bytes.NewBuffer([]byte(yaml))); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
// var conf Config
|
|
// if err := viper.UnmarshalExact(&conf); err != nil {
|
|
// t.Error(err)
|
|
// }
|
|
|
|
// _ = configureChargers(conf)
|
|
}
|