feat: add host actions, lifecycle hooks and operational tools
This commit is contained in:
1 parent
8d4915543e
commit
e5bde9c61f
32 files changed
+2083
-64
No files matched your search
@@ -698,3 +698,24 @@ func TestSaveCommandsRoundTrip(t *testing.T) {
|
||||
t.Fatalf("commands lost: %+v", got.Commands)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperationsRoundTrip(t *testing.T) {
|
||||
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||||
cfg := config.Config{
|
||||
NetBox: config.NetBoxConfig{URL: "https://netbox.example", Token: "token"},
|
||||
TUI: config.TUIConfig{HistoryLimit: 25},
|
||||
Activity: config.ActivityConfig{Enabled: true, RetentionDays: 7, MaxEntries: 50},
|
||||
SSH: config.SSHConfig{SSHOptions: config.SSHOptions{PostDisconnect: "echo done"}, Rules: []config.SSHRule{{Match: config.SSHMatch{Tag: "lab"}, SSHOptions: config.SSHOptions{PostDisconnect: "none"}}}},
|
||||
Commands: map[string]config.HostCommand{"mtr": {Args: []string{"mtr", "{address}"}, AliasPrefix: "m", Timeout: "10s", Confirm: true, PostRun: "echo done", Match: config.SSHMatch{Tag: "router", Instance: "prod"}}},
|
||||
}
|
||||
if err := save(cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err := config.Load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got.TUI != cfg.TUI || got.Activity != cfg.Activity || !reflect.DeepEqual(got.Commands, cfg.Commands) || !reflect.DeepEqual(got.SSH, cfg.SSH) {
|
||||
t.Fatalf("round trip lost operations: %+v", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user