github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/config/api_test.go (about) 1 package config 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 func TestAPIValidate(t *testing.T) { 9 err := DefaultAPI().Validate() 10 if err != nil { 11 t.Errorf("error validating default api: %s", err) 12 } 13 } 14 15 func TestAPICopy(t *testing.T) { 16 a := DefaultAPI() 17 b := a.Copy() 18 19 a.Enabled = !a.Enabled 20 a.Address = "foo" 21 a.Webui = !a.Webui 22 a.ServeRemoteTraffic = !a.ServeRemoteTraffic 23 a.AllowedOrigins = []string{"bar"} 24 25 if a.Enabled == b.Enabled { 26 t.Errorf("Enabled fields should not match") 27 } 28 if a.Address == b.Address { 29 t.Errorf("Address fields should not match") 30 } 31 if a.Webui == b.Webui { 32 t.Errorf("Webui fields should not match") 33 } 34 if a.ServeRemoteTraffic == b.ServeRemoteTraffic { 35 t.Errorf("ServeRemoteTraffic fields should not match") 36 } 37 if reflect.DeepEqual(a.AllowedOrigins, b.AllowedOrigins) { 38 t.Errorf("AllowedOrigins fields should not match") 39 } 40 }