MCPcopy
hub / github.com/1Panel-dev/KubePi / TestGetLoginIPAreaFallback

Function TestGetLoginIPAreaFallback

internal/api/v1/session/login_log_test.go:26–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24}
25
26func TestGetLoginIPAreaFallback(t *testing.T) {
27 tests := []struct {
28 name string
29 ip string
30 want string
31 }{
32 {name: "loopback", ip: loginIPLocalAddress, want: loginIPLocalArea},
33 {name: "private ipv4", ip: "192.168.1.10", want: loginIPPrivateArea},
34 {name: "private ipv6", ip: "fd00::1", want: loginIPPrivateArea},
35 {name: "public ipv6", ip: "2001:db8::1", want: loginIPUnknownArea},
36 {name: "invalid ip", ip: "not-an-ip", want: loginIPUnknownArea},
37 }
38
39 for _, tt := range tests {
40 t.Run(tt.name, func(t *testing.T) {
41 if got := getLoginIPArea(tt.ip); got != tt.want {
42 t.Fatalf("getLoginIPArea() = %q, want %q", got, tt.want)
43 }
44 })
45 }
46}

Callers

nothing calls this directly

Calls 2

getLoginIPAreaFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected