Exemplo n.º 1
0
func Valves() map[int]*models.Valve {
	relays := make(map[int]*models.Valve)

	valves, err := config.GetList("valves")
	if err != nil {
		log.Fatalf("Could not load the valves id: %v", err)
	}

	for _, value := range valves {
		valve, err := strconv.Atoi(value)
		if err != nil {
			log.Printf("Valve %s could not be configured. Ignoring")
		}
		relays[valve] = models.FirstValveOrCreate(valve)
	}

	return relays
}
Exemplo n.º 2
0
func TestValveCreation(t *testing.T) {
	valve := models.FirstValveOrCreate(17)
	if valve.RelayId != 17 {
		t.Fail()
	}
}