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

     1  package config_test
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  
     7  	"github.com/qri-io/qri/config"
     8  	testcfg "github.com/qri-io/qri/config/test"
     9  )
    10  
    11  func TestP2PValidate(t *testing.T) {
    12  	err := testcfg.DefaultP2PForTesting().Validate()
    13  	if err != nil {
    14  		t.Errorf("error validating default p2p: %s", err)
    15  	}
    16  }
    17  
    18  func TestP2PCopy(t *testing.T) {
    19  	cases := []struct {
    20  		p2p *config.P2P
    21  	}{
    22  		{testcfg.DefaultP2PForTesting()},
    23  	}
    24  	for i, c := range cases {
    25  		cpy := c.p2p.Copy()
    26  		if !reflect.DeepEqual(cpy, c.p2p) {
    27  			t.Errorf("P2P Copy test case %v, p2p structs are not equal: \ncopy: %v, \noriginal: %v", i, cpy, c.p2p)
    28  			continue
    29  		}
    30  		cpy.QriBootstrapAddrs[0] = ""
    31  		if reflect.DeepEqual(cpy, c.p2p) {
    32  			t.Errorf("P2P Copy test case %v, editing one p2p struct should not affect the other: \ncopy: %v, \noriginal: %v", i, cpy, c.p2p)
    33  			continue
    34  		}
    35  	}
    36  }