Explorar el Código

etcdhttp: simple test for peer set cleanup

Xiang Li hace 11 años
padre
commit
f4a33dd6df
Se han modificado 1 ficheros con 21 adiciones y 0 borrados
  1. 21 0
      etcdserver/etcdhttp/peers_test.go

+ 21 - 0
etcdserver/etcdhttp/peers_test.go

@@ -0,0 +1,21 @@
+package etcdhttp
+
+import "testing"
+
+//TODO: full testing for peer set
+func TestPeerSet(t *testing.T) {
+	p := &Peers{}
+
+	p.Set("0x1=1.1.1.1")
+	if p.Pick(0x1) != "http://1.1.1.1" {
+		t.Errorf("pick = %s, want http://1.1.1.1", p.Pick(0x1))
+	}
+
+	p.Set("0x2=2.2.2.2")
+	if p.Pick(0x1) != "" {
+		t.Errorf("pick = %s, want empty string", p.Pick(0x1))
+	}
+	if p.Pick(0x2) != "http://2.2.2.2" {
+		t.Errorf("pick = %s, want http://2.2.2.2", p.Pick(0x2))
+	}
+}