MCPcopy
hub / github.com/go-task/task / Run

Method Run

task_test.go:408–440  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

406}
407
408func (fct fileContentTest) Run(t *testing.T) {
409 t.Helper()
410
411 for f := range fct.Files {
412 _ = os.Remove(filepathext.SmartJoin(fct.Dir, f))
413 }
414
415 e := task.NewExecutor(
416 task.WithDir(fct.Dir),
417 task.WithTempDir(task.TempDir{
418 Remote: filepathext.SmartJoin(fct.Dir, ".task"),
419 Fingerprint: filepathext.SmartJoin(fct.Dir, ".task"),
420 }),
421 task.WithEntrypoint(fct.Entrypoint),
422 task.WithStdout(io.Discard),
423 task.WithStderr(io.Discard),
424 )
425
426 require.NoError(t, e.Setup(), "e.Setup()")
427 require.NoError(t, e.Run(t.Context(), &task.Call{Task: fct.Target}), "e.Run(target)")
428 for name, expectContent := range fct.Files {
429 t.Run(fct.name(name), func(t *testing.T) {
430 path := filepathext.SmartJoin(e.Dir, name)
431 b, err := os.ReadFile(path)
432 require.NoError(t, err, "Error reading file")
433 s := string(b)
434 if fct.TrimSpace {
435 s = strings.TrimSpace(s)
436 }
437 assert.Equal(t, expectContent, s, "unexpected file content in %s", path)
438 })
439 }
440}
441
442func TestGenerates(t *testing.T) {
443 t.Parallel()

Calls 4

SetupMethod · 0.95
RunMethod · 0.95
nameMethod · 0.95
SmartJoinFunction · 0.92

Tested by

no test coverage detected