github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/repo/mem_repo_test.go (about)

     1  package repo
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/qri-io/qfs"
     8  	"github.com/qri-io/qfs/muxfs"
     9  	testcfg "github.com/qri-io/qri/config/test"
    10  	"github.com/qri-io/qri/dsref"
    11  	dsrefspec "github.com/qri-io/qri/dsref/spec"
    12  	"github.com/qri-io/qri/event"
    13  	"github.com/qri-io/qri/logbook/oplog"
    14  	"github.com/qri-io/qri/profile"
    15  )
    16  
    17  func TestMemRepoResolveRef(t *testing.T) {
    18  	ctx := context.Background()
    19  	fs, err := muxfs.New(ctx, []qfs.Config{
    20  		{Type: "mem"},
    21  	})
    22  	if err != nil {
    23  		t.Fatal(err)
    24  	}
    25  
    26  	pro, err := profile.NewProfile(testcfg.DefaultProfileForTesting())
    27  	if err != nil {
    28  		t.Fatal(err)
    29  	}
    30  
    31  	r, err := NewMemRepoWithProfile(ctx, pro, fs, event.NilBus)
    32  	if err != nil {
    33  		t.Fatalf("error creating repo: %s", err.Error())
    34  	}
    35  
    36  	dsrefspec.AssertResolverSpec(t, r, func(ref dsref.Ref, author *profile.Profile, log *oplog.Log) error {
    37  		return r.Logbook().MergeLog(ctx, author.PubKey, log)
    38  	})
    39  }