MCPcopy Create free account
hub / github.com/github/gh-aw / TestValidatePromptTmpPaths

Function TestValidatePromptTmpPaths

pkg/workflow/compiler_validators_test.go:585–636  ·  view source on GitHub ↗

TestValidatePromptTmpPaths tests that validatePromptTmpPaths increments the warning counter and emits a message when the markdown body has problematic /tmp paths.

(t *testing.T)

Source from the content-addressed store, hash-verified

583// TestValidatePromptTmpPaths tests that validatePromptTmpPaths increments the
584// warning counter and emits a message when the markdown body has problematic /tmp paths.
585func TestValidatePromptTmpPaths(t *testing.T) {
586 tests := []struct {
587 name string
588 markdown string
589 expectWarn bool
590 }{
591 {
592 name: "no tmp reference — no warning",
593 markdown: "# Hello\n\nDo some work.",
594 expectWarn: false,
595 },
596 {
597 name: "correct /tmp/gh-aw/agent/ — no warning",
598 markdown: "Store results in /tmp/gh-aw/agent/output.txt",
599 expectWarn: false,
600 },
601 {
602 name: "bare /tmp/ reference — warning",
603 markdown: "Save artifacts to /tmp/data.json",
604 expectWarn: true,
605 },
606 {
607 name: "/tmp/gh-aw/ subpath — no warning",
608 markdown: "Write summary to /tmp/gh-aw/summary.txt",
609 expectWarn: false,
610 },
611 }
612
613 for _, tt := range tests {
614 t.Run(tt.name, func(t *testing.T) {
615 tmpDir := testutil.TempDir(t, "tmp-path-test")
616 markdownPath := filepath.Join(tmpDir, "workflow.md")
617
618 compiler := NewCompiler()
619 workflowData := &WorkflowData{
620 Name: "Test",
621 MarkdownContent: tt.markdown,
622 AI: "copilot",
623 }
624
625 before := compiler.GetWarningCount()
626 compiler.validatePromptTmpPaths(workflowData, markdownPath)
627 after := compiler.GetWarningCount()
628
629 if tt.expectWarn {
630 assert.Greater(t, after, before, "warning count should have increased")
631 } else {
632 assert.Equal(t, before, after, "warning count should not have changed")
633 }
634 })
635 }
636}

Callers

nothing calls this directly

Calls 5

GetWarningCountMethod · 0.95
TempDirFunction · 0.92
NewCompilerFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected