23 lines
425 B
Go
23 lines
425 B
Go
package ups
|
|
|
|
import "testing"
|
|
|
|
func TestParseNUT(t *testing.T) {
|
|
raw := `battery.runtime: 384
|
|
ups.status: OB LB
|
|
`
|
|
s, err := parseNUT(raw)
|
|
if err != nil {
|
|
t.Fatalf("parseNUT returned error: %v", err)
|
|
}
|
|
if !s.OnBattery {
|
|
t.Fatalf("expected OnBattery=true")
|
|
}
|
|
if !s.LowBattery {
|
|
t.Fatalf("expected LowBattery=true")
|
|
}
|
|
if s.RuntimeSeconds != 384 {
|
|
t.Fatalf("expected runtime 384, got %d", s.RuntimeSeconds)
|
|
}
|
|
}
|