github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/lib/resolve_test.go (about) 1 package lib 2 3 import ( 4 "context" 5 "errors" 6 "testing" 7 8 "github.com/qri-io/qri/dsref" 9 repotest "github.com/qri-io/qri/repo/test" 10 ) 11 12 func TestResolveReference(t *testing.T) { 13 tr, err := repotest.NewTempRepo("ruh_roh", "inst_resolve_ref", repotest.NewTestCrypto()) 14 if err != nil { 15 t.Fatal(err) 16 } 17 defer tr.Delete() 18 19 cfg := tr.GetConfig() 20 cfg.Registry = nil 21 tr.WriteConfigFile() 22 23 ctx := context.Background() 24 inst, err := NewInstance(ctx, tr.QriPath) 25 if err != nil { 26 t.Fatal(err) 27 } 28 29 ref := &dsref.Ref{ 30 Username: "example", 31 Name: "dataset", 32 } 33 _, err = inst.ResolveReference(ctx, ref, "") 34 if !errors.Is(err, dsref.ErrRefNotFound) { 35 t.Errorf(`unexpected error resolving ref with 36 default resolver and no configured registry. 37 want: %q 38 got: %q`, dsref.ErrRefNotFound, err) 39 } 40 }