MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestParseTemplate

Function TestParseTemplate

internal/plugins/command-runner/config_test.go:63–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestParseTemplate(t *testing.T) {
64 tests := []struct {
65 name string
66 cmd string
67 wantParams []string
68 }{
69 {
70 name: "no parameters",
71 cmd: "uptime",
72 wantParams: nil,
73 },
74 {
75 name: "single parameter",
76 cmd: "systemctl status {service}",
77 wantParams: []string{"service"},
78 },
79 {
80 name: "multiple parameters",
81 cmd: "journalctl -u {service} -n {lines}",
82 wantParams: []string{"service", "lines"},
83 },
84 }
85
86 for _, tt := range tests {
87 t.Run(tt.name, func(t *testing.T) {
88 template := ParseTemplate(tt.cmd)
89 if len(template.Parameters) != len(tt.wantParams) {
90 t.Errorf("ParseTemplate() got %d params, want %d", len(template.Parameters), len(tt.wantParams))
91 return
92 }
93 for i, param := range template.Parameters {
94 if param != tt.wantParams[i] {
95 t.Errorf("ParseTemplate() param[%d] = %v, want %v", i, param, tt.wantParams[i])
96 }
97 }
98 })
99 }
100}
101
102func TestCommandTemplate_FillTemplate(t *testing.T) {
103 tests := []struct {

Callers

nothing calls this directly

Calls 2

ParseTemplateFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected