TestDebugArgsModule tests module execution - requires actual variable
(t *testing.T)
| 53 | |
| 54 | // TestDebugArgsModule tests module execution - requires actual variable |
| 55 | func TestDebugArgsModule(t *testing.T) { |
| 56 | testcases := []struct { |
| 57 | name string |
| 58 | opt internal.ExecOptions |
| 59 | expectStdout string |
| 60 | expectError bool |
| 61 | description string |
| 62 | }{ |
| 63 | { |
| 64 | name: "missing both msg and var", |
| 65 | opt: internal.ExecOptions{ |
| 66 | Host: "node1", |
| 67 | Variable: NewTestVariable([]string{"node1"}, nil), |
| 68 | Args: createRawArgs(map[string]any{}), |
| 69 | }, |
| 70 | expectStdout: internal.StdoutFailed, |
| 71 | expectError: true, |
| 72 | description: "When both msg and var are missing, should return failed", |
| 73 | }, |
| 74 | } |
| 75 | |
| 76 | for _, tc := range testcases { |
| 77 | t.Run(tc.name, func(t *testing.T) { |
| 78 | ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| 79 | defer cancel() |
| 80 | stdout, stderr, err := ModuleDebug(ctx, tc.opt) |
| 81 | require.Equal(t, tc.expectStdout, stdout, tc.description) |
| 82 | if tc.expectError { |
| 83 | require.Error(t, err, tc.description) |
| 84 | require.NotEmpty(t, stderr, tc.description) |
| 85 | } else { |
| 86 | require.NoError(t, err, tc.description) |
| 87 | } |
| 88 | }) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // TestDebugArgsParse tests argument parsing edge cases. |
| 93 | func TestDebugArgsParse(t *testing.T) { |
nothing calls this directly
no test coverage detected