Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/engine/patch_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -1630,5 +1630,11 @@ func (p *customDiffPatch) toJSONPatch(path string) []map[string]any {
}

func (p *customDiffPatch) summary(path string) string {
type summarizer interface {
Summary() string
}
if s, ok := p.patch.(summarizer); ok {
return s.Summary()
}
return "CustomPatch"
}
20 changes: 20 additions & 0 deletions internal/engine/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,26 @@ func TestCustomDiffPatch_ToJSONPatch(t *testing.T) {
}
}

func TestCustomDiffPatch_Summary(t *testing.T) {
t.Run("delegates to inner Summary", func(t *testing.T) {
custom := &customDiffPatch{patch: summarizerFunc("Text update")}
if got := custom.summary(""); got != "Text update" {
t.Errorf("expected %q, got %q", "Text update", got)
}
})

t.Run("falls back to CustomPatch when no Summary method", func(t *testing.T) {
custom := &customDiffPatch{patch: struct{}{}}
if got := custom.summary(""); got != "CustomPatch" {
t.Errorf("expected %q, got %q", "CustomPatch", got)
}
})
}

type summarizerFunc string

func (s summarizerFunc) Summary() string { return string(s) }

func TestPatch_Summary(t *testing.T) {
type Config struct {
Name string
Expand Down
Loading