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") } }
func TestLoadWithParseFailures(t *testing.T) { if err := etcdtest.DeleteAll(); err != nil { t.Error(err) return } etcdtest.PutData("catalog", `Path("/pdp") -> "https://catalog.example.org"`) etcdtest.PutData("cms", "invalid expression") c, err := New(Options{etcdtest.Urls, "/skippertest", 0, false}) if err != nil { t.Error(err) return } routeInfo, err := c.LoadAndParseAll() if err != nil { t.Error(err) } if len(routeInfo) != 2 { t.Error("failed to load all routes", len(routeInfo)) } var parseError error for _, ri := range routeInfo { if ri.ParseError != nil { if parseError != nil { t.Error("too many errors") } parseError = ri.ParseError } } if parseError == nil { t.Error("failed to detect parse error") } }
func TestCheckEtcdInvalid(t *testing.T) { urls, err := stringsToUrls(etcdtest.Urls...) if err != nil { t.Error(err) } etcdtest.DeleteAll() etcdtest.PutData("route1", "invalid doc") if err != nil { t.Error(err) } err = checkCmd(cmdArgs{in: &medium{typ: etcd, urls: urls, path: "/skippertest"}}) if err != invalidRouteExpression { t.Error("failed to fail properly") } }
func TestCheckEtcd(t *testing.T) { urls, err := stringsToUrls(etcdtest.Urls...) if err != nil { t.Error(err) } etcdtest.DeleteAll() etcdtest.PutData("route1", `Method("POST") -> <shunt>`) if err != nil { t.Error(err) } err = checkCmd(cmdArgs{in: &medium{typ: etcd, urls: urls, path: "/skippertest"}}) if err != nil { t.Error(err) } }
func TestCheckEtcd(t *testing.T) { urls, err := stringsToUrls(etcdtest.Urls...) if err != nil { t.Error(err) } etcdtest.DeleteAll() etcdtest.PutData("route1", `Method("POST") -> <shunt>`) if err != nil { t.Error(err) } readClient, _ := createReadClient(&medium{typ: etcd, urls: urls, path: "/skippertest"}) err = checkCmd(readClient, nil, nil) if err != nil { t.Error(err) } }