Test / test (pull_request) Successful in 4m15s
- info/open/whois: NetBox details (site, nested locations, rack units, role, platform, tenant, IPs per interface), web page, reverse IP lookup - cache status, site, role, platform, tenant, location chain and rack; ask before connecting to hosts in ssh.warn_status (--force skips) - ssh rules and command restrictions match site/role/platform/tenant/status - tui.columns selects what the TUI shows; optional TCP reachability column; detail view (Ctrl+L), NetBox page (Ctrl+G), status/location filters - resolver.fallback tries other strategies' addresses when unreachable - copy-id, known-hosts reset and address-change notices - export ansible (YAML/INI) and export ssh-config - token: keyring stores NetBox tokens in the system keyring - fix stale menu number in testenv configure test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
862 B
Go
31 lines
862 B
Go
package resolver
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"git.zb-server.de/Sebi/ssh-netbox-wrapper/internal/config"
|
|
"git.zb-server.de/Sebi/ssh-netbox-wrapper/internal/netbox"
|
|
)
|
|
|
|
func TestCandidatesListsEveryStrategyOnce(t *testing.T) {
|
|
chain, err := New(config.ResolverConfig{Strategies: []string{"primary_ip", "hostname"}, HostnameDomain: "example.com"})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
entry := &netbox.HostEntry{Name: "web", Kind: "vm", PrimaryIP4: "10.0.0.1", PrimaryIP6: "2001:db8::1"}
|
|
got, err := chain.Candidates(context.Background(), entry, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := []Candidate{{"10.0.0.1", "primary_ip"}, {"web.example.com", "hostname"}, {"2001:db8::1", "primary_ip"}}
|
|
if len(got) != len(want) {
|
|
t.Fatalf("got %+v", got)
|
|
}
|
|
for i := range want {
|
|
if got[i] != want[i] {
|
|
t.Fatalf("got %+v, want %+v", got, want)
|
|
}
|
|
}
|
|
}
|