feat(go): add capacity health check tool
This commit is contained in:
31
go/vehicle-gateway/cmd/capacity-check/main_test.go
Normal file
31
go/vehicle-gateway/cmd/capacity-check/main_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseEndpoints(t *testing.T) {
|
||||
endpoints := parseEndpoints("gateway=http://127.0.0.1:20211/metrics, fast=http://127.0.0.1:20215/metrics")
|
||||
|
||||
if len(endpoints) != 2 {
|
||||
t.Fatalf("len = %d, want 2: %#v", len(endpoints), endpoints)
|
||||
}
|
||||
if endpoints[0].Name != "gateway" || endpoints[0].URL != "http://127.0.0.1:20211/metrics" {
|
||||
t.Fatalf("endpoint[0] = %#v", endpoints[0])
|
||||
}
|
||||
if endpoints[1].Name != "fast" || endpoints[1].URL != "http://127.0.0.1:20215/metrics" {
|
||||
t.Fatalf("endpoint[1] = %#v", endpoints[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseEndpointsUsesDefaultMetricsURLWhenOnlyBaseURLIsProvided(t *testing.T) {
|
||||
endpoints := parseEndpoints("gateway=http://127.0.0.1:20211")
|
||||
|
||||
if len(endpoints) != 1 {
|
||||
t.Fatalf("len = %d, want 1", len(endpoints))
|
||||
}
|
||||
if !strings.HasSuffix(endpoints[0].URL, "/metrics") {
|
||||
t.Fatalf("url = %q, want /metrics suffix", endpoints[0].URL)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user