Initial commit

This commit is contained in:
2026-05-10 11:40:53 +02:00
commit 140d736fc7
16 changed files with 1917 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
package openapi
import (
"strings"
"testing"
)
func TestDiffParser(t *testing.T) {
input := `diff --git a/pkg/openapi/session.go b/pkg/openapi/session.go
index 1234567..89abcdef 100644
--- a/pkg/openapi/session.go
+++ b/pkg/openapi/session.go
@@ -1,3 +1,4 @@
package openapi
import (
+ "os"
diff --git a/main.go b/main.go
index 0000000..1111111
--- a/main.go
+++ b/main.go
@@ -10,1 +10,1 @@
-old
+new
`
var blocks []DiffBlock
parser := NewDiffParser(func(b DiffBlock) {
blocks = append(blocks, b)
})
err := parser.Parse(strings.NewReader(input))
if err != nil {
t.Fatalf("Parse failed: %v", err)
}
if len(blocks) != 2 {
t.Errorf("Expected 2 blocks, got %d", len(blocks))
}
if blocks[0].File != "pkg/openapi/session.go" {
t.Errorf("Expected first file pkg/openapi/session.go, got %s", blocks[0].File)
}
if blocks[1].File != "main.go" {
t.Errorf("Expected second file main.go, got %s", blocks[1].File)
}
if !strings.Contains(blocks[1].Content, "+new") {
t.Errorf("Expected block 1 to contain '+new', got %s", blocks[1].Content)
}
}