github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/base/dsfs/compute_fields_test.go (about)

     1  package dsfs
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/qri-io/dataset"
     8  	"github.com/qri-io/qfs"
     9  	"github.com/qri-io/qri/event"
    10  )
    11  
    12  func TestComputeFieldsFile(t *testing.T) {
    13  	ctx := context.Background()
    14  	ds := &dataset.Dataset{
    15  		Commit: &dataset.Commit{},
    16  		Structure: &dataset.Structure{
    17  			Format:      dataset.NDJSONDataFormat.String(),
    18  			Compression: "zst",
    19  			Schema:      dataset.BaseSchemaArray,
    20  		},
    21  	}
    22  
    23  	ds.SetBodyFile(qfs.NewMemfileBytes(ds.Structure.BodyFilename(), []byte("[0,1,2]\n[3,4,5]")))
    24  	cff, err := newComputeFieldsFile(ctx, event.NilBus, nil, ds, nil, &SaveSwitches{})
    25  	if err != nil {
    26  		t.Fatal(err)
    27  	}
    28  
    29  	expect := "/body.ndjson.zst"
    30  	if expect != cff.FileName() {
    31  		t.Errorf("unexpected filename. want: %q got %q", expect, cff.FileName())
    32  	}
    33  }