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

     1  package config
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestRegistryValidate(t *testing.T) {
     9  	err := DefaultRegistry().Validate()
    10  	if err != nil {
    11  		t.Errorf("error validating default registry: %s", err)
    12  	}
    13  }
    14  
    15  func TestRegistryCopy(t *testing.T) {
    16  	cases := []struct {
    17  		registry *Registry
    18  	}{
    19  		{DefaultRegistry()},
    20  	}
    21  	for i, c := range cases {
    22  		cpy := c.registry.Copy()
    23  		if !reflect.DeepEqual(cpy, c.registry) {
    24  			t.Errorf("Registry Copy test case %v, registry structs are not equal: \ncopy: %v, \noriginal: %v", i, cpy, c.registry)
    25  			continue
    26  		}
    27  		cpy.Location = "different/location"
    28  		if reflect.DeepEqual(cpy, c.registry) {
    29  			t.Errorf("Registry Copy test case %v, editing one registry struct should not affect the other: \ncopy: %v, \noriginal: %v", i, cpy, c.registry)
    30  			continue
    31  		}
    32  	}
    33  }