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

Function TestSplitContentIntoChunks

pkg/workflow/xml_comments_test.go:253–291  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

251}
252
253func TestSplitContentIntoChunks(t *testing.T) {
254 // Test short content - should result in single chunk
255 shortContent := "# Short content\n\nThis is a brief workflow description."
256 chunks := splitContentIntoChunks(shortContent)
257 if len(chunks) != 1 {
258 t.Errorf("Short content should result in 1 chunk, got %d", len(chunks))
259 }
260 if chunks[0] != shortContent {
261 t.Error("Short content should be unchanged in single chunk")
262 }
263
264 // Test content that exceeds the limit - should result in multiple chunks
265 longLine := "This is a very long line of content that will be repeated many times to exceed the character limit."
266 longContent := strings.Repeat(longLine+"\n", 400)
267 chunks = splitContentIntoChunks(longContent)
268
269 if len(chunks) <= 1 {
270 t.Errorf("Long content should result in multiple chunks, got %d", len(chunks))
271 }
272
273 // Verify that each chunk stays within the size limit
274 const maxChunkSize = 20900
275 for i, chunk := range chunks {
276 lines := strings.Split(chunk, "\n")
277 estimatedSize := 0
278 for _, line := range lines {
279 estimatedSize += 10 + len(line) + 1 // 10 spaces indentation + line + newline
280 }
281 if estimatedSize > maxChunkSize {
282 t.Errorf("Chunk %d exceeds size limit: %d > %d", i, estimatedSize, maxChunkSize)
283 }
284 }
285
286 // Verify that joining chunks recreates original content (minus potential trailing newline)
287 rejoined := strings.Join(chunks, "\n")
288 if strings.TrimSuffix(rejoined, "\n") != strings.TrimSuffix(longContent, "\n") {
289 t.Error("Joined chunks should recreate original content")
290 }
291}
292
293func TestCompileWorkflowWithChunking(t *testing.T) {
294 // Create temporary directory for test files

Callers

nothing calls this directly

Calls 3

splitContentIntoChunksFunction · 0.85
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected