MCPcopy Create free account
hub / github.com/charmbracelet/bubbletea / TestExecProcessProgramResumeToken

Function TestExecProcessProgramResumeToken

programresume_test.go:154–182  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

152}
153
154func 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}

Callers

nothing calls this directly

Calls 7

RunMethod · 0.95
successExecCommandFunction · 0.85
NewProgramFunction · 0.85
WithInputFunction · 0.85
WithOutputFunction · 0.85
WithEnvironmentFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected