github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/test/devstack/submit_test.go (about) 1 //go:build integration 2 3 package devstack 4 5 import ( 6 "context" 7 "testing" 8 9 "github.com/filecoin-project/bacalhau/pkg/node" 10 testutils "github.com/filecoin-project/bacalhau/pkg/test/utils" 11 12 "github.com/filecoin-project/bacalhau/pkg/logger" 13 _ "github.com/filecoin-project/bacalhau/pkg/logger" 14 "github.com/filecoin-project/bacalhau/pkg/model" 15 "github.com/filecoin-project/bacalhau/pkg/requester/publicapi" 16 "github.com/filecoin-project/bacalhau/pkg/system" 17 "github.com/stretchr/testify/require" 18 "github.com/stretchr/testify/suite" 19 ) 20 21 type DevstackSubmitSuite struct { 22 suite.Suite 23 } 24 25 // In order for 'go test' to run this suite, we need to create 26 // a normal test function and pass our suite to suite.Run 27 func TestDevstackSubmitSuite(t *testing.T) { 28 suite.Run(t, new(DevstackSubmitSuite)) 29 } 30 31 // Before each test 32 func (suite *DevstackSubmitSuite) SetupTest() { 33 logger.ConfigureTestLogging(suite.T()) 34 err := system.InitConfigForTesting(suite.T()) 35 require.NoError(suite.T(), err) 36 } 37 38 func (suite *DevstackSubmitSuite) TestEmptySpec() { 39 ctx := context.Background() 40 41 stack, _ := testutils.SetupTest( 42 ctx, 43 suite.T(), 44 45 1, 46 0, 47 false, 48 node.NewComputeConfigWithDefaults(), 49 node.NewRequesterConfigWithDefaults(), 50 ) 51 52 apiUri := stack.Nodes[0].APIServer.GetURI() 53 apiClient := publicapi.NewRequesterAPIClient(apiUri) 54 55 j := &model.Job{} 56 j.Spec.Deal = model.Deal{Concurrency: 1} 57 _, missingSpecError := apiClient.Submit(ctx, j) 58 59 require.Error(suite.T(), missingSpecError) 60 61 j = &model.Job{} 62 j.Spec = model.Spec{Engine: model.EngineDocker} 63 _, missingDealError := apiClient.Submit(ctx, j) 64 require.Error(suite.T(), missingDealError) 65 }