github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/test/devstack/publish_on_error_test.go (about)

     1  //go:build integration
     2  
     3  package devstack
     4  
     5  import (
     6  	"testing"
     7  
     8  	"github.com/filecoin-project/bacalhau/pkg/job"
     9  	_ "github.com/filecoin-project/bacalhau/pkg/logger"
    10  	"github.com/filecoin-project/bacalhau/pkg/model"
    11  	"github.com/filecoin-project/bacalhau/pkg/test/scenario"
    12  	"github.com/stretchr/testify/suite"
    13  )
    14  
    15  type PublishOnErrorSuite struct {
    16  	scenario.ScenarioRunner
    17  }
    18  
    19  // In order for 'go test' to run this suite, we need to create
    20  // a normal test function and pass our suite to suite.Run
    21  func TestPublishOnErrorSuite(t *testing.T) {
    22  	suite.Run(t, new(PublishOnErrorSuite))
    23  }
    24  
    25  func (s *PublishOnErrorSuite) TestPublishOnError() {
    26  	stdoutText := "I am a miserable failure\n"
    27  
    28  	testcase := scenario.Scenario{
    29  		Inputs: scenario.StoredText(stdoutText, "data/hello.txt"),
    30  		Spec: model.Spec{
    31  			Engine:    model.EngineWasm,
    32  			Verifier:  model.VerifierNoop,
    33  			Publisher: model.PublisherIpfs,
    34  			Wasm: model.JobSpecWasm{
    35  				EntryPoint:  scenario.CatFileToStdout.Spec.Wasm.EntryPoint,
    36  				EntryModule: scenario.CatFileToStdout.Spec.Wasm.EntryModule,
    37  				Parameters: []string{
    38  					"data/hello.txt",
    39  					"does/not/exist.txt",
    40  				},
    41  			},
    42  		},
    43  		ResultsChecker: scenario.FileEquals(model.DownloadFilenameStdout, stdoutText),
    44  		JobCheckers: []job.CheckStatesFunction{
    45  			job.WaitForSuccessfulCompletion(),
    46  		},
    47  	}
    48  
    49  	s.RunScenario(testcase)
    50  }