diff --git a/common/helpers/bimap.go b/common/helpers/bimap.go index f3b7577e..98ac2a40 100644 --- a/common/helpers/bimap.go +++ b/common/helpers/bimap.go @@ -33,24 +33,6 @@ func (bi *Bimap[K, V]) LoadKey(v V) (K, bool) { return k, ok } -// Keys returns a slice of the keys in the bimap. -func (bi *Bimap[K, V]) Keys() []K { - var keys []K - for k := range bi.forward { - keys = append(keys, k) - } - return keys -} - -// Values returns a slice of the values in the bimap. -func (bi *Bimap[K, V]) Values() []V { - var values []V - for v := range bi.inverse { - values = append(values, v) - } - return values -} - // String returns a string representation of the bimap. func (bi *Bimap[K, V]) String() string { return fmt.Sprintf("Bi%v", bi.forward) diff --git a/common/helpers/bimap_test.go b/common/helpers/bimap_test.go index 1654423c..357c5a83 100644 --- a/common/helpers/bimap_test.go +++ b/common/helpers/bimap_test.go @@ -59,29 +59,3 @@ func TestBimapLoadKey(t *testing.T) { } } } - -func TestBimapKeys(t *testing.T) { - input := helpers.NewBimap(map[int]string{ - 1: "hello", - 2: "world", - 3: "happy", - }) - got := input.Keys() - expected := []int{1, 2, 3} - if diff := helpers.Diff(got, expected); diff != "" { - t.Errorf("Keys() (-want, +got):\n%s", diff) - } -} - -func TestBimapValues(t *testing.T) { - input := helpers.NewBimap(map[int]string{ - 1: "hello", - 2: "world", - 3: "happy", - }) - got := input.Values() - expected := []string{"hello", "world", "happy"} - if diff := helpers.Diff(got, expected); diff != "" { - t.Errorf("Values() (-want, +got):\n%s", diff) - } -} diff --git a/console/graph.go b/console/graph.go index 6dec47ae..d83bcbdb 100644 --- a/console/graph.go +++ b/console/graph.go @@ -513,7 +513,3 @@ func (c *Component) graphHandlerFunc(gc *gin.Context) { gc.JSON(http.StatusOK, output) } - -func (c *Component) graphFieldsHandlerFunc(gc *gin.Context) { - gc.JSON(http.StatusOK, graphColumnMap.Values()) -} diff --git a/console/graph_test.go b/console/graph_test.go index 9cf486b1..9e96dee1 100644 --- a/console/graph_test.go +++ b/console/graph_test.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" netHTTP "net/http" - "sort" "strings" "testing" "time" @@ -521,71 +520,3 @@ func TestGraphHandler(t *testing.T) { t.Fatalf("POST /api/v0/console/graph (-got, +want):\n%s", diff) } } - -func TestGraphFieldsHandler(t *testing.T) { - r := reporter.NewMock(t) - ch, _ := clickhousedb.NewMock(t, r) - h := http.NewMock(t, r) - c, err := New(r, Configuration{}, Dependencies{ - Daemon: daemon.NewMock(t), - HTTP: h, - ClickHouseDB: ch, - }) - if err != nil { - t.Fatalf("New() error:\n%+v", err) - } - helpers.StartStop(t, c) - - resp, err := netHTTP.Get(fmt.Sprintf("http://%s/api/v0/console/graph/fields", h.Address)) - if err != nil { - t.Fatalf("POST /api/v0/console/graph/fields:\n%+v", err) - } - defer resp.Body.Close() - if resp.StatusCode != 200 { - t.Errorf("POST /api/v0/console/graph/fields: got status code %d, not 200", resp.StatusCode) - } - gotContentType := resp.Header.Get("Content-Type") - if gotContentType != "application/json; charset=utf-8" { - t.Errorf("POST /api/v0/console/graph/fields Content-Type (-got, +want):\n-%s\n+%s", - gotContentType, "application/json; charset=utf-8") - } - decoder := json.NewDecoder(resp.Body) - var got []string - if err := decoder.Decode(&got); err != nil { - t.Fatalf("POST /api/v0/console/graph error:\n%+v", err) - } - expected := []string{ - "ExporterAddress", - "ExporterName", - "ExporterGroup", - "SrcAddr", - "DstAddr", - "SrcAS", - "DstAS", - "SrcCountry", - "DstCountry", - "InIfName", - "OutIfName", - "InIfDescription", - "OutIfDescription", - "InIfSpeed", - "OutIfSpeed", - "InIfConnectivity", - "OutIfConnectivity", - "InIfProvider", - "OutIfProvider", - "InIfBoundary", - "OutIfBoundary", - "EType", - "Proto", - "SrcPort", - "DstPort", - "ForwardingStatus", - } - sort.Strings(expected) - sort.Strings(got) - - if diff := helpers.Diff(got, expected); diff != "" { - t.Fatalf("POST /api/v0/console/graph/fields (-got, +want):\n%s", diff) - } -} diff --git a/console/root.go b/console/root.go index 7f144b68..02e516c6 100644 --- a/console/root.go +++ b/console/root.go @@ -82,7 +82,6 @@ func (c *Component) Start() error { c.d.HTTP.GinRouter.GET("/api/v0/console/widget/top/:name", c.widgetTopHandlerFunc) c.d.HTTP.GinRouter.GET("/api/v0/console/widget/graph", c.widgetGraphHandlerFunc) c.d.HTTP.GinRouter.POST("/api/v0/console/graph", c.graphHandlerFunc) - c.d.HTTP.GinRouter.GET("/api/v0/console/graph/fields", c.graphFieldsHandlerFunc) c.t.Go(func() error { ticker := time.NewTicker(10 * time.Second)