TestDebugModule tests the actual functionality of the debug module.
(t *testing.T)
| 154 | |
| 155 | // TestDebugModule tests the actual functionality of the debug module. |
| 156 | func TestDebugModule(t *testing.T) { |
| 157 | testcases := []struct { |
| 158 | name string |
| 159 | hosts []string |
| 160 | vars map[string]any |
| 161 | args map[string]any |
| 162 | expectError bool |
| 163 | description string |
| 164 | }{ |
| 165 | { |
| 166 | name: "print simple message", |
| 167 | hosts: []string{"node1"}, |
| 168 | vars: nil, |
| 169 | args: map[string]any{"msg": "Hello World"}, |
| 170 | expectError: false, |
| 171 | description: "Should print simple message successfully", |
| 172 | }, |
| 173 | { |
| 174 | name: "print variable value", |
| 175 | hosts: []string{"node1"}, |
| 176 | vars: map[string]any{"message": "Hello from variable"}, |
| 177 | args: map[string]any{"msg": "{{ .message }}"}, |
| 178 | expectError: false, |
| 179 | description: "Should print variable value successfully", |
| 180 | }, |
| 181 | { |
| 182 | name: "print number", |
| 183 | hosts: []string{"node1"}, |
| 184 | vars: nil, |
| 185 | args: map[string]any{"msg": 42}, |
| 186 | expectError: false, |
| 187 | description: "Should print number successfully", |
| 188 | }, |
| 189 | { |
| 190 | name: "print object", |
| 191 | hosts: []string{"node1"}, |
| 192 | vars: nil, |
| 193 | args: map[string]any{"msg": map[string]any{"key": "value"}}, |
| 194 | expectError: false, |
| 195 | description: "Should print object successfully", |
| 196 | }, |
| 197 | // New test cases for var field |
| 198 | { |
| 199 | name: "print var with template syntax", |
| 200 | hosts: []string{"node1"}, |
| 201 | vars: map[string]any{"version": "v1.0.0"}, |
| 202 | args: map[string]any{"var": "{{ .version }}"}, |
| 203 | expectError: false, |
| 204 | description: "Should print var with template syntax successfully", |
| 205 | }, |
| 206 | { |
| 207 | name: "print var with simple path", |
| 208 | hosts: []string{"node1"}, |
| 209 | vars: map[string]any{"config": map[string]any{"name": "test"}}, |
| 210 | args: map[string]any{"var": ".config.name"}, |
| 211 | expectError: false, |
| 212 | description: "Should print var with simple path successfully", |
| 213 | }, |
nothing calls this directly
no test coverage detected