Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
MOCK_PACKAGES = \
gobot \
http \
log \
prometheus \
twillio \
vendor/github.com/prometheus/client_golang/api/prometheus \
vendor/github.com/hybridgroup/gobot

build-mocks:
for dir in $(MOCK_PACKAGES); do \
mockery -dir=./$$dir/ -all -case underscore -note "*DO NOT EDIT* Auto-generated via mockery"; \
done

deps:
glide update
56 changes: 51 additions & 5 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions gobot/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ import (
"github.com/pkg/errors"
)

type Prober interface {
Target(temp messages.Temp) (messages.Temp, error)
Setpoint() (messages.Temp, error)
HighThreshold(temp messages.Temp)
LowThreshold(temp messages.Temp)
Alerts() chan qpid.Notification
Temperature() (messages.Temp, error)
Location() messages.Location
Description() string
Source() string
}

// Probe is a thermocoupler connected to a raspberry pi
type Probe struct {
id int
Expand Down Expand Up @@ -86,13 +98,13 @@ func (g *Probe) Temperature() (messages.Temp, error) {
}

var final uint
fmt.Println("b0,b1:", b[0],b[1])
fmt.Println("b0,b1:", b[0], b[1])

final = uint(b[0]) << 8
final = final + uint(b[1])
final = final / 5

fmt.Println("b0,b1,final:", b[0],b[1],final)
fmt.Println("b0,b1,final:", b[0], b[1], final)

g.temperature = messages.Temp(int(final))
return g.temperature, e
Expand Down
11 changes: 11 additions & 0 deletions gobot/rpi.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ var (
MetricsIntervalSeconds = 5
)

type Controllerer interface {
FoodMonitors() []qpid.Monitor
GrillMonitor() qpid.Monitor
Run() error
Stop() error
Status() (qpid.GrillStatus, error)
Notifications() chan qpid.Notification
Metrics() chan qpid.GrillStatus
Source() string
}

// Controller represents all the electronics that
// make the PID work
type Controller struct {
Expand Down
4 changes: 4 additions & 0 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
"github.com/bbqgophers/qpid"
)

type Logger interface {
Listen(n chan qpid.Notification)
}

// Log implements the qpid.NotificationSink interface
// logging messages to standard out (for now)
type Log struct {
Expand Down
55 changes: 55 additions & 0 deletions mocks/Adaptor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package mocks

import "github.com/stretchr/testify/mock"

// *DO NOT EDIT* Auto-generated via mockery

type Adaptor struct {
mock.Mock
}

// Name provides a mock function with given fields:
func (_m *Adaptor) Name() string {
ret := _m.Called()

var r0 string
if rf, ok := ret.Get(0).(func() string); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(string)
}

return r0
}

// Connect provides a mock function with given fields:
func (_m *Adaptor) Connect() []error {
ret := _m.Called()

var r0 []error
if rf, ok := ret.Get(0).(func() []error); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]error)
}
}

return r0
}

// Finalize provides a mock function with given fields:
func (_m *Adaptor) Finalize() []error {
ret := _m.Called()

var r0 []error
if rf, ok := ret.Get(0).(func() []error); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]error)
}
}

return r0
}
62 changes: 62 additions & 0 deletions mocks/Client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package mocks

import "github.com/stretchr/testify/mock"

import "net/http"
import "net/url"

import "golang.org/x/net/context"

// *DO NOT EDIT* Auto-generated via mockery

type Client struct {
mock.Mock
}

// url provides a mock function with given fields: ep, args
func (_m *Client) url(ep string, args map[string]string) *url.URL {
ret := _m.Called(ep, args)

var r0 *url.URL
if rf, ok := ret.Get(0).(func(string, map[string]string) *url.URL); ok {
r0 = rf(ep, args)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*url.URL)
}
}

return r0
}

// do provides a mock function with given fields: _a0, _a1
func (_m *Client) do(_a0 context.Context, _a1 *http.Request) (*http.Response, []byte, error) {
ret := _m.Called(_a0, _a1)

var r0 *http.Response
if rf, ok := ret.Get(0).(func(context.Context, *http.Request) *http.Response); ok {
r0 = rf(_a0, _a1)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*http.Response)
}
}

var r1 []byte
if rf, ok := ret.Get(1).(func(context.Context, *http.Request) []byte); ok {
r1 = rf(_a0, _a1)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).([]byte)
}
}

var r2 error
if rf, ok := ret.Get(2).(func(context.Context, *http.Request) error); ok {
r2 = rf(_a0, _a1)
} else {
r2 = ret.Error(2)
}

return r0, r1, r2
}
46 changes: 46 additions & 0 deletions mocks/Commander.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package mocks

import "github.com/stretchr/testify/mock"

// *DO NOT EDIT* Auto-generated via mockery

type Commander struct {
mock.Mock
}

// Command provides a mock function with given fields: _a0
func (_m *Commander) Command(_a0 string) func(map[string]interface{}) interface{} {
ret := _m.Called(_a0)

var r0 func(map[string]interface{}) interface{}
if rf, ok := ret.Get(0).(func(string) func(map[string]interface{}) interface{}); ok {
r0 = rf(_a0)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(func(map[string]interface{}) interface{})
}
}

return r0
}

// Commands provides a mock function with given fields:
func (_m *Commander) Commands() map[string]func(map[string]interface{}) interface{} {
ret := _m.Called()

var r0 map[string]func(map[string]interface{}) interface{}
if rf, ok := ret.Get(0).(func() map[string]func(map[string]interface{}) interface{}); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(map[string]func(map[string]interface{}) interface{})
}
}

return r0
}

// AddCommand provides a mock function with given fields: name, command
func (_m *Commander) AddCommand(name string, command func(map[string]interface{}) interface{}) {
_m.Called(name, command)
}
Loading