Ejemplo n.º 1
0
import (
	"fmt"
	"io/ioutil"
	"os"
	"path"

	"github.com/cswank/gogadgets"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("boiler", func() {
	var (
		tmp    string
		sys    map[string]string
		boiler gogadgets.OutputDevice
		pin    *gogadgets.Pin
	)
	BeforeEach(func() {
		var err error
		tmp, err = ioutil.TempDir("", "")
		Expect(err).To(BeNil())
		sys = setupGPIO(tmp, gogadgets.Pins["gpio"]["8"]["11"])
		gogadgets.GPIO_DEV_PATH = tmp
		gogadgets.GPIO_DEV_MODE = 0777
	})

	AfterEach(func() {
		os.RemoveAll(tmp)
	})
	Describe("heater", func() {
Ejemplo n.º 2
0
	"github.com/cswank/gogadgets"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

type thermCase struct {
	temperature float64
	output      string
}

var _ = Describe("thermostat", func() {
	var (
		tmp   string
		sys   map[string]string
		therm gogadgets.OutputDevice
		pin   *gogadgets.Pin
		val   *gogadgets.Value
	)
	BeforeEach(func() {
		var err error
		tmp, err = ioutil.TempDir("", "")
		Expect(err).To(BeNil())
		sys = setupGPIOs(
			tmp,
			map[string]string{
				"heat": gogadgets.Pins["gpio"]["8"]["11"],
				"cool": gogadgets.Pins["gpio"]["8"]["12"],
				"fan":  gogadgets.Pins["gpio"]["8"]["14"],
			})
		gogadgets.GPIO_DEV_PATH = tmp