aboutsummaryrefslogtreecommitdiff
path: root/lib/git/git_test.go
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2021-01-06 01:24:48 +0700
committerShulhan <m.shulhan@gmail.com>2021-01-06 01:24:48 +0700
commit13f240c9848c7c959ea476a4b236e49181177725 (patch)
tree1376a00aea14f32d882e25bc8db2aa3fe5510928 /lib/git/git_test.go
parentae0e03ebec6061d5a85ebe54ac4c77cef18f1972 (diff)
downloadpakakeh.go-13f240c9848c7c959ea476a4b236e49181177725.tar.xz
git: fix test due to changes on exit status on git client
To prevent the test error when running with different git client, we use the strings.Contains to compare the error instead of using test.Assert directly.
Diffstat (limited to 'lib/git/git_test.go')
-rw-r--r--lib/git/git_test.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/git/git_test.go b/lib/git/git_test.go
index 928fdb0d..07bdb735 100644
--- a/lib/git/git_test.go
+++ b/lib/git/git_test.go
@@ -7,6 +7,7 @@ package git
import (
"fmt"
"os"
+ "strings"
"testing"
"github.com/shuLhan/share/lib/test"
@@ -311,12 +312,12 @@ func TestRemoteChange(t *testing.T) {
expStdout string
}{{
desc: "With empty oldName",
- expErr: "RemoteChange: exit status 128",
+ expErr: "RemoteChange: exit status",
expStderr: "fatal: No such remote: ''\n",
}, {
desc: "With empty newName",
oldName: "origin",
- expErr: "RemoteChange: exit status 128",
+ expErr: "RemoteChange: exit status",
expStderr: "fatal: '' is not a valid remote name\n",
}}
@@ -326,7 +327,10 @@ func TestRemoteChange(t *testing.T) {
err := RemoteChange(_testRepoDir, c.oldName, c.newName, c.newURL)
if err != nil {
- test.Assert(t, "err", c.expErr, err.Error(), true)
+ if strings.Contains(err.Error(), c.expErr) {
+ continue
+ }
+ t.Fatalf("expecting error like %q, got %q", c.expErr, err.Error())
}
test.Assert(t, "stderr", c.expStderr, mock.Error(), true)