Пример #1
0
func TestResetLoadExistingFails(t *testing.T) {
	etcdtest.DeleteAllFrom(defaultEtcdPrefix)

	in := &medium{typ: inline, eskip: `route2: Method("POST") -> <shunt>`}
	out := &medium{typ: etcd, urls: testEtcdUrls, path: defaultEtcdPrefix}
	err := etcdtest.PutDataTo(defaultEtcdPrefix, "route1", "invalid doc")
	if err != nil {
		t.Error(err)
	}

	err = resetCmd(cmdArgs{in: in, out: out})
	if err != nil {
		t.Error(err)
	}

	_, err = etcdtest.GetNodeFrom(defaultEtcdPrefix, "route1")
	if err == nil {
		t.Error(err)
	}

	_, err = etcdtest.GetNodeFrom(defaultEtcdPrefix, "route2")
	if err != nil {
		t.Error(err)
	}
}
Пример #2
0
func TestResetLoadExistingFails(t *testing.T) {
	etcdtest.DeleteAllFrom(defaultEtcdPrefix)

	in := &medium{typ: inline, eskip: `route2: Method("POST") -> <shunt>`}
	out := &medium{typ: etcd, urls: testEtcdUrls, path: defaultEtcdPrefix}
	writeClient, _ := createWriteClient(out)
	readOutClient, _ := createReadClient(out)
	readClient, _ := createReadClient(in)

	err := etcdtest.PutDataTo(defaultEtcdPrefix, "route1", "invalid doc")
	if err != nil {
		t.Error(err)
	}

	err = resetCmd(readClient, readOutClient, writeClient)
	if err != nil {
		t.Error(err)
	}

	_, err = etcdtest.GetNodeFrom(defaultEtcdPrefix, "route1")
	if err == nil {
		t.Error(err)
	}

	_, err = etcdtest.GetNodeFrom(defaultEtcdPrefix, "route2")
	if err != nil {
		t.Error(err)
	}
}