(t *testing.T)
| 152 | } |
| 153 | |
| 154 | func TestExecProcessProgramResumeToken(t *testing.T) { |
| 155 | t.Parallel() |
| 156 | |
| 157 | tokenVar := ansi.ProgramResumeTokenEnv + "=" + testResumeToken |
| 158 | for name, tc := range map[string]struct { |
| 159 | resume *ProgramResume |
| 160 | wantToken bool |
| 161 | }{ |
| 162 | "reporting": {&ProgramResume{Args: []string{"app"}}, false}, |
| 163 | "not reporting": {nil, true}, |
| 164 | } { |
| 165 | t.Run(name, func(t *testing.T) { |
| 166 | t.Parallel() |
| 167 | cmd := successExecCommand() |
| 168 | cmd.Env = append(os.Environ(), tokenVar) |
| 169 | p := NewProgram(&execResumeModel{cmd: cmd, resume: tc.resume}, |
| 170 | WithInput(&bytes.Buffer{}), |
| 171 | WithOutput(&bytes.Buffer{}), |
| 172 | WithEnvironment([]string{tokenVar}), |
| 173 | ) |
| 174 | if _, err := p.Run(); err != nil { |
| 175 | t.Fatal(err) |
| 176 | } |
| 177 | if got := slices.Contains(cmd.Env, tokenVar); got != tc.wantToken { |
| 178 | t.Errorf("child has the token = %v, want %v", got, tc.wantToken) |
| 179 | } |
| 180 | }) |
| 181 | } |
| 182 | } |
nothing calls this directly
no test coverage detected