Skip to content

Commit

Permalink
clientv3: relax the checking condition in test
Browse files Browse the repository at this point in the history
  • Loading branch information
jingyih committed Oct 3, 2018
1 parent 9ec2082 commit 647f6f1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions clientv3/snapshot/v3_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/url"
"os"
"path/filepath"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -170,17 +171,19 @@ func TestCorruptedBackupFileCheck(t *testing.T) {

sp := NewV3(zap.NewExample())
_, err := sp.Status(dbPath)
expectedErrString :=
"snapshot file integrity check failed. 2 errors found.\n" +
"page 3: already freed\n" +
"page 4: unreachable unfreed"
expectedErrKeywords := "snapshot file integrity check failed"
/* example error message:
snapshot file integrity check failed. 2 errors found.
page 3: already freed
page 4: unreachable unfreed
*/
if err == nil {
t.Errorf("expected to get the following error message, got no error\n%s", expectedErrString)
t.Error("expected error due to corrupted snapshot file, got no error")
}
if err.Error() != expectedErrString {
t.Errorf("expected error message:\n %s\n"+
"actual error message:\n %s",
expectedErrString, err.Error())
if !strings.Contains(err.Error(), expectedErrKeywords) {
t.Errorf("expected error message to contain the following keywords:\n%s\n"+
"actual error message:\n%s",
expectedErrKeywords, err.Error())
}
}

Expand Down

0 comments on commit 647f6f1

Please sign in to comment.