{149.0, "0"}, {129.0, "1"}, {131.0, "1"}, {149.0, "1"}, {129.0, "1"}, {150.0, "0"}, } for _, c := range cases { msg := &gogadgets.Message{ Sender: "my thermometer", Value: gogadgets.Value{ Value: c.temperature, }, } boiler.Update(msg) b, err := ioutil.ReadFile(sys["value"]) Expect(err).To(BeNil()) Expect(string(b)).To(Equal(c.output)) } }) }) Describe("cooler", func() { BeforeEach(func() { pin = &gogadgets.Pin{ Port: "8", Pin: "11", Direction: "out", Args: map[string]interface{}{ "type": "cooler",
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{ Sender: "my thermometer", Value: gogadgets.Value{ Value: 69.0, }, } therm.Update(msg)