-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding cli tests using testscript - gives 97.7% (all but logfatal and…
… actual 1 line main)
- Loading branch information
Showing
6 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,5 @@ REMOVED: gone1 | |
NEW: new1 | ||
NEW: new2 | ||
``` | ||
|
||
See also [delta.txtar](delta.txtar) for examples (tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# testscript framework tests for delta command line | ||
|
||
# Basic usage test | ||
! delta | ||
! stdout . | ||
stderr 'Need 2 arguments' | ||
|
||
# -version | ||
delta -version | ||
stdout 'path github.com/fortio/delta' | ||
! stderr . | ||
|
||
# -foo (bad flag) | ||
! delta -foo | ||
! stdout . | ||
stderr 'flag provided but not defined: -foo' | ||
|
||
# non existent input file A | ||
! delta foo1 foo2 | ||
stderr 'E Error reading file A: open foo1: no such file or directory' | ||
! stdout . | ||
|
||
# non existent input file B | ||
! delta oldFile foo2 | ||
stderr 'E Error reading file B: open foo2: no such file or directory' | ||
! stdout . | ||
|
||
# positive test (includes order of A/B iteration swap) | ||
delta -loglevel verbose -b 'echo NEW:' -a 'echo REMOVED:' oldFile newFile | ||
cmp stdout expected1 | ||
stderr 'Fortio delta.*started - will run "echo REMOVED:" on entries unique to oldFile, and "echo NEW:" on ones unique to newFile' | ||
stderr 'Swapping A and B iteration order as B is smaller' | ||
|
||
# swapping a and b test | ||
delta -loglevel verbose -a 'echo NEW:' -b 'echo REMOVED:' newFile oldFile | ||
cmp stdout expected2 | ||
! stderr 'Swapping A and B iteration order as B is smaller' | ||
|
||
-- expected1 -- | ||
REMOVED: gone 2 | ||
REMOVED: gone1 | ||
REMOVED: goneA | ||
REMOVED: goneZ | ||
NEW: new1 | ||
NEW: new2 | ||
-- expected2 -- | ||
NEW: new1 | ||
NEW: new2 | ||
REMOVED: gone 2 | ||
REMOVED: gone1 | ||
REMOVED: goneA | ||
REMOVED: goneZ | ||
-- oldFile -- | ||
goneZ | ||
old1 | ||
goneA | ||
old2 | ||
gone1 | ||
old3 | ||
gone 2 | ||
-- newFile -- | ||
new1 | ||
old1 | ||
old2 | ||
old3 | ||
new2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/rogpeppe/go-internal/testscript" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
os.Exit(testscript.RunMain(m, map[string]func() int{ | ||
"delta": Main, | ||
})) | ||
} | ||
|
||
func TestDelta(t *testing.T) { | ||
testscript.Run(t, testscript.Params{Dir: "./"}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
fortio.org/assert v1.1.2 h1:t6WGDqPD5VFrUvx30U0+3mgXXcoPonrdKqt0vfJHn8E= | ||
fortio.org/fortio v1.38.4-cli1 h1:qGGkqmh1soBVCKG+LZc4l3F3BE4oHVow6AUslunmzGU= | ||
fortio.org/fortio v1.38.4-cli1/go.mod h1:4DhI17BkI3sU0DR4Z2HwochdpphTae+8NgZwWy6epRk= | ||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A= | ||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= | ||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= | ||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= | ||
golang.org/x/exp v0.0.0-20221111204811-129d8d6c17ab h1:1S7USr8/C0Sgk4egxq4zZ07zYt2Xh1IiFp8hUMXH/us= | ||
golang.org/x/exp v0.0.0-20221111204811-129d8d6c17ab/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= |