var err error boiler, err = gogadgets.NewBoiler(pin) Expect(err).To(BeNil()) }) It("sets up the gpio stuff correctly", func() { b, err := ioutil.ReadFile(sys["direction"]) Expect(err).To(BeNil()) Expect(string(b)).To(Equal("out")) b, err = ioutil.ReadFile(sys["value"]) Expect(err).To(BeNil()) Expect(string(b)).To(Equal("0")) }) It("turns on", func() { Expect(boiler.On(nil)).To(BeNil()) b, err := ioutil.ReadFile(sys["value"]) Expect(err).To(BeNil()) Expect(string(b)).To(Equal("1")) }) It("turns off when the temperature is above range and back on when the temperature is below range", func() { Expect(boiler.On(nil)).To(BeNil()) b, err := ioutil.ReadFile(sys["value"]) Expect(err).To(BeNil()) Expect(string(b)).To(Equal("1")) cases := []thermCase{ {149.0, "1"}, {150.0, "0"}, {149.0, "0"}, {129.0, "1"},
Cmd: "heat house to 70 F", Value: float64(70.0), } }) It("sets up the gpio stuff correctly", func() { b, err := ioutil.ReadFile(sys["heat-direction"]) Expect(err).To(BeNil()) Expect(string(b)).To(Equal("out")) b, err = ioutil.ReadFile(sys["heat-value"]) Expect(err).To(BeNil()) Expect(string(b)).To(Equal("0")) }) It("turns on", func() { Expect(therm.On(val)).To(BeNil()) msg := &gogadgets.Message{ Sender: "my thermometer", Value: gogadgets.Value{ Value: 69.0, }, } therm.Update(msg) b, err := ioutil.ReadFile(sys["heat-value"]) Expect(err).To(BeNil()) Expect(string(b)).To(Equal("1")) }) It("turns off when the temperature is above range and back on when the temperature is below range", func() { Expect(therm.On(val)).To(BeNil()) msg := &gogadgets.Message{