Пример #1
0
func TestReceiveDelete(t *testing.T) {
	if err := etcdtest.ResetData(); err != nil {
		t.Error(err)
		return
	}

	c, err := New(Options{etcdtest.Urls, "/skippertest", 0, false})
	if err != nil {
		t.Error(err)
		return
	}

	c.LoadAll()

	etcdtest.DeleteData("pdp")

	rs, ds, err := c.LoadUpdate()
	if err != nil {
		t.Error(err)
	}

	if !checkDeleted(ds, "pdp") {
		t.Error("failed to receive the right deleted id")
	}

	if len(rs) != 0 {
		t.Error("unexpected upsert")
	}
}
Пример #2
0
func TestReceiveInsert(t *testing.T) {
	if err := etcdtest.ResetData(); err != nil {
		t.Error(err)
		return
	}

	c, err := New(Options{etcdtest.Urls, "/skippertest", 0, false})
	if err != nil {
		t.Error(err)
		return
	}

	_, err = c.LoadAll()
	if err != nil {
		t.Error(err)
	}

	etcdtest.PutData("catalog", `Path("/pdp") -> "https://catalog.example.org"`)

	rs, ds, err := c.LoadUpdate()
	if err != nil {
		t.Error(err)
	}

	if !checkBackend(rs, "catalog", "https://catalog.example.org") {
		t.Error("failed to receive the right backend")
	}

	if len(ds) != 0 {
		t.Error("unexpected delete")
	}
}
Пример #3
0
func TestReceivesInitial(t *testing.T) {
	if err := etcdtest.ResetData(); err != nil {
		t.Error(t)
		return
	}

	expectedEndpoints := strings.Join(etcdtest.Urls, ";")

	c, err := New(Options{etcdtest.Urls, "/skippertest", 0, false})
	if err != nil {
		t.Error(err)
		return
	}

	rs, err := c.LoadAll()

	if err != nil {
		t.Error(err)
	}

	if !checkInitial(rs) {
		t.Error("failed to receive the right docs")
	}

	if strings.Join(c.endpoints, ";") != expectedEndpoints {
		t.Error("wrong endpoints rotation")
	}
}
Пример #4
0
func TestReceivesInitial(t *testing.T) {
	if err := etcdtest.ResetData(); err != nil {
		t.Error(t)
		return
	}

	c, err := New(Options{etcdtest.Urls, "/skippertest", 0, false})
	if err != nil {
		t.Error(err)
		return
	}

	rs, err := c.LoadAll()

	if err != nil {
		t.Error(err)
	}

	if !checkInitial(rs) {
		t.Error("failed to receive the right docs")
	}
}