Skip to content

Commit f4ab6d0

Browse files
committed
Add path option test
1 parent 41d91e8 commit f4ab6d0

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tests/main.t

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,59 @@ Testing lineinfile mode without match:
292292
this is the foobar forth foobar line
293293
this is the last line
294294
___xxx
295+
296+
297+
298+
Testing replace mode with path option:
299+
300+
$ cat > test.txt <<EOF
301+
> this is a testline
302+
> this is the second line
303+
> this is the third foobar line
304+
> this is the foobar forth foobar line
305+
> this is the last line
306+
> EOF
307+
$ mkdir -p testing/sub1/subsub testing/sub2/subsub
308+
$ cp test.txt testing/sub1/subsub/test1.txt
309+
$ cp test.txt testing/sub1/subsub/test2.txt
310+
$ cp test.txt testing/sub1/test3.txt
311+
$ cp test.txt testing/sub2/subsub/test4.txt
312+
$ cp test.txt testing/sub2/subsub/test5.txt
313+
$ cp test.txt testing/sub2/original.md
314+
$ goreplace -s foobar -r barfoo --path=./testing --path-pattern='*.txt'
315+
$ cat testing/sub1/subsub/test1.txt
316+
this is a testline
317+
this is the second line
318+
this is the third barfoo line
319+
this is the barfoo forth barfoo line
320+
this is the last line
321+
$ cat testing/sub1/subsub/test2.txt
322+
this is a testline
323+
this is the second line
324+
this is the third barfoo line
325+
this is the barfoo forth barfoo line
326+
this is the last line
327+
$ cat testing/sub1/test3.txt
328+
this is a testline
329+
this is the second line
330+
this is the third barfoo line
331+
this is the barfoo forth barfoo line
332+
this is the last line
333+
$ cat testing/sub2/subsub/test4.txt
334+
this is a testline
335+
this is the second line
336+
this is the third barfoo line
337+
this is the barfoo forth barfoo line
338+
this is the last line
339+
$ cat testing/sub2/subsub/test5.txt
340+
this is a testline
341+
this is the second line
342+
this is the third barfoo line
343+
this is the barfoo forth barfoo line
344+
this is the last line
345+
$ cat testing/sub2/original.md
346+
this is a testline
347+
this is the second line
348+
this is the third foobar line
349+
this is the foobar forth foobar line
350+
this is the last line

0 commit comments

Comments
 (0)