awesome-patterns/playground/mocklib/robot_test.go

34 lines
609 B
Go
Raw Permalink Normal View History

2018-09-26 18:48:20 +03:00
package mocklib
import (
"testing"
2020-05-04 18:01:38 +03:00
"github.com/crazybber/go-patterns/playground/mocklib/mocks"
2018-09-26 18:48:20 +03:00
)
func TestStartRobots(t *testing.T) {
StartRobots()
}
func TestMakeRobotsSayHi(t *testing.T) {
// create an instance of our test object
mockRobotA := new(mocks.Robot)
mockRobotB := new(mocks.Robot)
// setup expectations
mockRobotA.On("SayHi").Return(nil, nil)
mockRobotB.On("SayHi").Return(nil, nil)
robots := []Robot{
mockRobotA,
mockRobotB,
}
// Act
makeRobotsSayHi(robots)
// Assert that the expectations were met
mockRobotA.AssertExpectations(t)
mockRobotB.AssertExpectations(t)
}