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

     1  //go:build unit || !integration
     2  
     3  package publicapi
     4  
     5  import (
     6  	"context"
     7  	"testing"
     8  
     9  	"github.com/filecoin-project/bacalhau/pkg/logger"
    10  	"github.com/filecoin-project/bacalhau/pkg/model"
    11  	testutils "github.com/filecoin-project/bacalhau/pkg/test/utils"
    12  	"github.com/stretchr/testify/require"
    13  )
    14  
    15  func TestGet(t *testing.T) {
    16  	logger.ConfigureTestLogging(t)
    17  	n, c := setupNodeForTest(t)
    18  	defer n.CleanupManager.Cleanup(context.Background())
    19  
    20  	ctx := context.Background()
    21  
    22  	// Submit a few random jobs to the node:
    23  	var err error
    24  	var j *model.Job
    25  	for i := 0; i < 5; i++ {
    26  		genericJob := testutils.MakeGenericJob()
    27  		j, err = c.Submit(ctx, genericJob)
    28  		require.NoError(t, err)
    29  	}
    30  
    31  	// Should be able to look up one of them:
    32  	job2, ok, err := c.Get(ctx, j.Metadata.ID)
    33  	require.NoError(t, err)
    34  	require.True(t, ok)
    35  	require.Equal(t, job2.Job.Metadata.ID, j.Metadata.ID)
    36  }