Skip to content

Commit

Permalink
use the same pin values for all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martha-johnston committed Oct 1, 2024
1 parent 9174f33 commit f1d9216
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions components/gantry/singleaxis/singleaxis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,16 @@ var fakeFrame = &referenceframe.LinkConfig{

var badFrame = &referenceframe.LinkConfig{}

var (
count = 0
defaultPinValues = []int{1, 1, 0}
limitPinValues = []int{1, 0, 1, 0, 1, 1, 0}
)
// alternate high and low to replicate the behavior of a gantry hitting and moving away from a limit switch
var defaultPinValues = []int{1, 0, 1, 0, 1, 1, 0}

func createFakeMotor() motor.Motor {
return &inject.Motor{
PropertiesFunc: func(ctx context.Context, extra map[string]interface{}) (motor.Properties, error) {
return motor.Properties{PositionReporting: true}, nil
},
PositionFunc: func(ctx context.Context, extra map[string]interface{}) (float64, error) {
return float64(count + 1), nil
return 1.0, nil
},
ResetZeroPositionFunc: func(ctx context.Context, offset float64, extra map[string]interface{}) error { return nil },
GoToFunc: func(ctx context.Context, rpm, position float64, extra map[string]interface{}) error { return nil },
Expand Down Expand Up @@ -270,7 +267,7 @@ func TestHome(t *testing.T) {
logger := logging.NewTestLogger(t)
fakegantry := &singleAxis{
motor: createFakeMotor(),
board: createFakeBoard(limitPinValues),
board: createFakeBoard(defaultPinValues),
limitHigh: true,
logger: logger,
rpm: float64(300),
Expand Down Expand Up @@ -310,7 +307,7 @@ func TestHome(t *testing.T) {

fakegantry = &singleAxis{
motor: createFakeMotor(),
board: createFakeBoard(limitPinValues),
board: createFakeBoard(defaultPinValues),
limitHigh: true,
logger: logger,
rpm: float64(300),
Expand All @@ -331,7 +328,7 @@ func TestHome(t *testing.T) {

fakegantry = &singleAxis{
motor: createFakeMotor(),
board: createFakeBoard(limitPinValues),
board: createFakeBoard(defaultPinValues),
limitHigh: true,
logger: logger,
rpm: float64(300),
Expand All @@ -348,7 +345,7 @@ func TestHomeLimitSwitch(t *testing.T) {
logger := logging.NewTestLogger(t)
fakegantry := &singleAxis{
motor: createFakeMotor(),
board: createFakeBoard(limitPinValues),
board: createFakeBoard(defaultPinValues),
limitHigh: true,
logger: logger,
rpm: float64(300),
Expand Down Expand Up @@ -445,7 +442,7 @@ func TestHomeLimitSwitch2(t *testing.T) {
logger := logging.NewTestLogger(t)
fakegantry := &singleAxis{
motor: createFakeMotor(),
board: createFakeBoard(limitPinValues),
board: createFakeBoard(defaultPinValues),
limitHigh: true,
logger: logger,
rpm: float64(300),
Expand Down Expand Up @@ -530,7 +527,7 @@ func TestTestLimit(t *testing.T) {
fakegantry := &singleAxis{
limitSwitchPins: []string{"1", "2"},
motor: createFakeMotor(),
board: createFakeBoard(limitPinValues),
board: createFakeBoard(defaultPinValues),
rpm: float64(300),
limitHigh: true,
opMgr: operation.NewSingleOperationManager(),
Expand Down

0 comments on commit f1d9216

Please sign in to comment.