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

     1  package config
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestRepoValidate(t *testing.T) {
     9  	err := DefaultRepo().Validate()
    10  	if err != nil {
    11  		t.Errorf("error validating default repo: %s", err)
    12  	}
    13  }
    14  
    15  func TestRepoCopy(t *testing.T) {
    16  	// build off DefaultRepo so we can test that the repo Copy
    17  	// actually copies over correctly (ie, deeply)
    18  	r := DefaultRepo()
    19  
    20  	cases := []struct {
    21  		repo *Repo
    22  	}{
    23  		{r},
    24  	}
    25  	for i, c := range cases {
    26  		cpy := c.repo.Copy()
    27  		if !reflect.DeepEqual(cpy, c.repo) {
    28  			t.Errorf("Repo Copy test case %v, repo structs are not equal: \ncopy: %v, \noriginal: %v", i, cpy, c.repo)
    29  			continue
    30  		}
    31  		cpy.Path = "newPath"
    32  		if reflect.DeepEqual(cpy, c.repo) {
    33  			t.Errorf("Repo Copy test case %v, editing one repo struct should not affect the other: \ncopy: %v, \noriginal: %v", i, cpy, c.repo)
    34  			continue
    35  		}
    36  	}
    37  }