func addSensors(config *config, srv *webserver.Webserver) error { for name, sensorConfig := range config.Sensors { s, err := sensor.New(sensorConfig.ID) if err != nil { return err } srv.AddSensor(name, s) } return nil }
"time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/alext/temperature-monitor/webserver" ) func TestWebServer(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Webserver") } var _ = Describe("the webserver", func() { var ( server *webserver.Webserver ) BeforeEach(func() { server = webserver.New(8080) }) Describe("the root page", func() { It("resturns a 200", func() { resp := doGetRequest(server, "/") Expect(resp.Code).To(Equal(http.StatusOK)) }) }) Describe("reading a sensor", func() {