github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/compute/bidstrategy/external_exec_strategy_test.go (about) 1 //go:build unit || !integration 2 3 package bidstrategy 4 5 import ( 6 "context" 7 "testing" 8 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestJobSelectionExec(t *testing.T) { 13 testCases := []struct { 14 name string 15 failMode bool 16 expectedResult bool 17 }{ 18 { 19 "fail the response and don't select the job", 20 true, 21 false, 22 }, 23 { 24 "succeed the response and select the job", 25 false, 26 true, 27 }, 28 } 29 30 for _, test := range testCases { 31 t.Run(test.name, func(t *testing.T) { 32 command := "exit 0" 33 if test.failMode { 34 command = "exit 1" 35 } 36 params := ExternalCommandStrategyParams{ 37 Command: command, 38 } 39 strategy := NewExternalCommandStrategy(params) 40 result, err := strategy.ShouldBid(context.Background(), getBidStrategyRequest()) 41 require.NoError(t, err) 42 require.Equal(t, test.expectedResult, result.ShouldBid) 43 }) 44 } 45 }