Beispiel #1
0
func DeleteRoute(route core.Route) error {
	// in case of failure
	oldRoutes, err := database.GetRoutes()
	if err != nil {
		return err
	}

	// apply to proxymgr
	err = proxymgr.DeleteRoute(route)
	if err != nil {
		return err
	}

	if !database.CentralStore {
		// save to backend
		err = database.DeleteRoute(route)
		if err != nil {
			// undo proxymgr action
			if uerr := proxymgr.SetRoutes(oldRoutes); uerr != nil {
				err = fmt.Errorf("%v - %v", err.Error(), uerr.Error())
			}
			return err
		}
	}
	return nil
}
Beispiel #2
0
func TestDeleteRoute(t *testing.T) {
	if err := proxymgr.DeleteRoute(testRoute); err != nil {
		t.Errorf("Failed to DELETE route - %v", err)
	}

	routes, err := proxymgr.GetRoutes()
	if err != nil {
		t.Error(err)
	}

	if len(routes) != 0 {
		t.Errorf("Failed to DELETE route")
	}
}