(t *testing.T)
| 251 | } |
| 252 | |
| 253 | func 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 | |
| 293 | func TestCompileWorkflowWithChunking(t *testing.T) { |
| 294 | // Create temporary directory for test files |
nothing calls this directly
no test coverage detected