MCPcopy
hub / github.com/harness/harness / Test_cutLinesFromFullDiff

Function Test_cutLinesFromFullDiff

git/api/diff_test.go:162–245  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

160}
161
162func Test_cutLinesFromFullDiff(t *testing.T) {
163 type args struct {
164 r io.Reader
165 startLine int
166 endLine int
167 }
168 tests := []struct {
169 name string
170 args args
171 wantW string
172 wantErr bool
173 }{
174 {
175 name: "test empty",
176 args: args{
177 r: strings.NewReader(`diff --git a/file.txt b/file.txt
178index f0eec86f614944a81f87d879ebdc9a79aea0d7ea..47d2739ba2c34690248c8f91b84bb54e8936899a 100644
179--- a/file.txt
180+++ b/file.txt
181@@ -0,0 +0,0 @@
182`),
183 startLine: 2,
184 endLine: 10,
185 },
186 wantW: `diff --git a/file.txt b/file.txt
187index f0eec86f614944a81f87d879ebdc9a79aea0d7ea..47d2739ba2c34690248c8f91b84bb54e8936899a 100644
188--- a/file.txt
189+++ b/file.txt
190@@ -0,0 +0,0 @@
191`,
192 },
193 {
194 name: "test 1",
195 args: args{
196 r: strings.NewReader(`diff --git a/file.txt b/file.txt
197index f0eec86f614944a81f87d879ebdc9a79aea0d7ea..47d2739ba2c34690248c8f91b84bb54e8936899a 100644
198--- a/file.txt
199+++ b/file.txt
200@@ -1,9 +1,9 @@
201some content
202some content
203some content
204-some content
205+some content
206some content
207some content
208some content
209some content
210some content
211`),
212 startLine: 2,
213 endLine: 10,
214 },
215 wantW: `diff --git a/file.txt b/file.txt
216index f0eec86f614944a81f87d879ebdc9a79aea0d7ea..47d2739ba2c34690248c8f91b84bb54e8936899a 100644
217--- a/file.txt
218+++ b/file.txt
219@@ -2,8 +2,8 @@

Callers

nothing calls this directly

Calls 5

cutLinesFromFullFileDiffFunction · 0.85
RunMethod · 0.65
DiffMethod · 0.65
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…