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

Function TestStatus

executor_test.go:526–672  ·  view source on GitHub ↗

TODO: mock fs

(t *testing.T)

Source from the content-addressed store, hash-verified

524
525// TODO: mock fs
526func TestStatus(t *testing.T) {
527 t.Parallel()
528
529 const dir = "testdata/status"
530
531 files := []string{
532 "foo.txt",
533 "bar.txt",
534 "baz.txt",
535 }
536
537 for _, f := range files {
538 path := filepathext.SmartJoin(dir, f)
539 _ = os.Remove(path)
540 if _, err := os.Stat(path); err == nil {
541 t.Errorf("File should not exist: %v", err)
542 }
543 }
544
545 // gen-foo creates foo.txt, and will always fail it's status check.
546 NewExecutorTest(t,
547 WithName("run gen-foo 1 silent"),
548 WithExecutorOptions(
549 task.WithDir(dir),
550 task.WithSilent(true),
551 ),
552 WithTask("gen-foo"),
553 )
554 // gen-foo creates bar.txt, and will pass its status-check the 3. time it
555 // is run. It creates bar.txt, but also lists it as its source. So, the checksum
556 // for the file won't match before after the second run as we the file
557 // only exists after the first run.
558 NewExecutorTest(t,
559 WithName("run gen-bar 1 silent"),
560 WithExecutorOptions(
561 task.WithDir(dir),
562 task.WithSilent(true),
563 ),
564 WithTask("gen-bar"),
565 )
566 // gen-silent-baz is marked as being silent, and should only produce output
567 // if e.Verbose is set to true.
568 NewExecutorTest(t,
569 WithName("run gen-baz silent"),
570 WithExecutorOptions(
571 task.WithDir(dir),
572 task.WithSilent(true),
573 ),
574 WithTask("gen-silent-baz"),
575 )
576
577 for _, f := range files {
578 if _, err := os.Stat(filepathext.SmartJoin(dir, f)); err != nil {
579 t.Errorf("File should exist: %v", err)
580 }
581 }
582
583 // Run gen-bar a second time to produce a checksum file that matches bar.txt

Callers

nothing calls this directly

Calls 6

SmartJoinFunction · 0.92
NewExecutorTestFunction · 0.85
WithNameFunction · 0.85
WithExecutorOptionsFunction · 0.85
WithTaskFunction · 0.85
WithFixtureTemplatingFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…