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

Function TestExtractWorkflowDescriptionFromFile

pkg/cli/add_description_test.go:101–146  ·  view source on GitHub ↗

TestExtractWorkflowDescriptionFromFile tests the ExtractWorkflowDescriptionFromFile function

(t *testing.T)

Source from the content-addressed store, hash-verified

99
100// TestExtractWorkflowDescriptionFromFile tests the ExtractWorkflowDescriptionFromFile function
101func TestExtractWorkflowDescriptionFromFile(t *testing.T) {
102 tests := []struct {
103 name string
104 content string
105 expected string
106 }{
107 {
108 name: "file with description",
109 content: `---
110name: Test Workflow
111description: This is a test workflow description from file
112on: push
113---
114
115# Test Workflow
116
117This is the workflow content.`,
118 expected: "This is a test workflow description from file",
119 },
120 {
121 name: "file without description",
122 content: `---
123name: Test Workflow
124on: push
125---
126
127# Test Workflow`,
128 expected: "",
129 },
130 }
131
132 for _, tt := range tests {
133 t.Run(tt.name, func(t *testing.T) {
134 // Create temporary file
135 tmpFile := testutil.TempDir(t, "test-*") + "/test-workflow.md"
136 if err := os.WriteFile(tmpFile, []byte(tt.content), 0644); err != nil {
137 t.Fatalf("Failed to create temp file: %v", err)
138 }
139
140 result := ExtractWorkflowDescriptionFromFile(tmpFile)
141 if result != tt.expected {
142 t.Errorf("ExtractWorkflowDescriptionFromFile() = %q, want %q", result, tt.expected)
143 }
144 })
145 }
146}
147
148// TestExtractWorkflowDescriptionFromFile_NonExistentFile tests handling of non-existent files
149func TestExtractWorkflowDescriptionFromFile_NonExistentFile(t *testing.T) {

Callers

nothing calls this directly

Calls 4

TempDirFunction · 0.92
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected