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

Function TestReadWorkflowFileWithAbsolutePath

pkg/cli/workflows_path_test.go:48–78  ·  view source on GitHub ↗

TestReadWorkflowFileWithAbsolutePath tests that readWorkflowFile correctly handles absolute paths

(t *testing.T)

Source from the content-addressed store, hash-verified

46
47// TestReadWorkflowFileWithAbsolutePath tests that readWorkflowFile correctly handles absolute paths
48func TestReadWorkflowFileWithAbsolutePath(t *testing.T) {
49 // Create a temporary directory structure
50 tempDir := testutil.TempDir(t, "test-*")
51 workflowsDir := filepath.Join(tempDir, ".github", "workflows")
52 if err := os.MkdirAll(workflowsDir, 0755); err != nil {
53 t.Fatalf("Failed to create workflows directory: %v", err)
54 }
55
56 // Create a test workflow file
57 testFile := filepath.Join(workflowsDir, "test-workflow.md")
58 testContent := []byte("---\non: push\n---\n# Test Workflow")
59 if err := os.WriteFile(testFile, testContent, 0644); err != nil {
60 t.Fatalf("Failed to write test file: %v", err)
61 }
62
63 // Test reading the workflow file with an absolute path
64 // The workflowsDir parameter should be ignored when filePath is absolute
65 content, path, err := readWorkflowFile(testFile, workflowsDir)
66 if err != nil {
67 t.Errorf("readWorkflowFile failed with absolute path: %v", err)
68 }
69
70 if string(content) != string(testContent) {
71 t.Errorf("Content mismatch. Expected: %s, Got: %s", testContent, content)
72 }
73
74 // The returned path should be the absolute path
75 if path != testFile {
76 t.Errorf("Path mismatch. Expected: %s, Got: %s", testFile, path)
77 }
78}
79
80// TestReadWorkflowFilePathSeparators tests that the function works correctly regardless of path separator
81func TestReadWorkflowFilePathSeparators(t *testing.T) {

Callers

nothing calls this directly

Calls 3

TempDirFunction · 0.92
readWorkflowFileFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected