diff options
| author | Shulhan <ms@kilabit.info> | 2021-03-14 22:37:59 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-03-14 22:40:05 +0700 |
| commit | e7552ad0189f761875bc1c2ca3dd716d43a01e0d (patch) | |
| tree | fd68ec29d23fb9a807a7382088020e3b17d446fd /lib/memfs | |
| parent | 882727d89c8e7f9b9761009ccdca1af8c18d0a30 (diff) | |
| download | pakakeh.go-e7552ad0189f761875bc1c2ca3dd716d43a01e0d.tar.xz | |
all: refactoring the test.Assert and test.AssertBench signature
Previously, the test.Assert and test.AssertBench functions has the
boolean parameter to print the stack trace of test in case its not equal.
Since this parameter is not mandatory and its usually always set to
"true", we remove them from function signature to simplify the call
to Assert and AssertBench.
Diffstat (limited to 'lib/memfs')
| -rw-r--r-- | lib/memfs/generate_test/memfs_generate_test.go | 6 | ||||
| -rw-r--r-- | lib/memfs/memfs_test.go | 18 | ||||
| -rw-r--r-- | lib/memfs/node_test.go | 14 |
3 files changed, 19 insertions, 19 deletions
diff --git a/lib/memfs/generate_test/memfs_generate_test.go b/lib/memfs/generate_test/memfs_generate_test.go index 21b504f7..73539cff 100644 --- a/lib/memfs/generate_test/memfs_generate_test.go +++ b/lib/memfs/generate_test/memfs_generate_test.go @@ -55,13 +55,13 @@ func TestGeneratePathNode(t *testing.T) { got, err := memFS.Get(c.path) if err != nil { - test.Assert(t, "error", c.expError, err.Error(), true) + test.Assert(t, "error", c.expError, err.Error()) continue } childs := got.Childs got.Childs = nil - test.Assert(t, "Node", c.exp, got, true) + test.Assert(t, "Node", c.exp, got) got.Childs = childs } } @@ -129,6 +129,6 @@ func TestNode_Readdir(t *testing.T) { sort.Strings(got) - test.Assert(t, "Node.Readdir", c.exp, got, true) + test.Assert(t, "Node.Readdir", c.exp, got) } } diff --git a/lib/memfs/memfs_test.go b/lib/memfs/memfs_test.go index e158a9ef..fade66c9 100644 --- a/lib/memfs/memfs_test.go +++ b/lib/memfs/memfs_test.go @@ -70,7 +70,7 @@ func TestAddFile(t *testing.T) { got, err := mfs.AddFile(c.intPath, c.extPath) if err != nil { - test.Assert(t, "error", c.expError, err.Error(), true) + test.Assert(t, "error", c.expError, err.Error()) continue } @@ -81,7 +81,7 @@ func TestAddFile(t *testing.T) { got.Childs = nil } - test.Assert(t, "AddFile", c.exp, got, true) + test.Assert(t, "AddFile", c.exp, got) if c.exp == nil { continue @@ -99,7 +99,7 @@ func TestAddFile(t *testing.T) { got.Childs = nil } - test.Assert(t, "Get", c.exp, got, true) + test.Assert(t, "Get", c.exp, got) } } @@ -178,16 +178,16 @@ func TestGet(t *testing.T) { got, err := mfs.Get(c.path) if err != nil { - test.Assert(t, "error", c.expErr, err, true) + test.Assert(t, "error", c.expErr, err) continue } if got.size <= opts.MaxFileSize { - test.Assert(t, "node.V", c.expV, got.V, true) + test.Assert(t, "node.V", c.expV, got.V) } test.Assert(t, "node.ContentType", c.expContentType, - got.ContentType, true) + got.ContentType) } } @@ -282,12 +282,12 @@ func TestMemFS_mount(t *testing.T) { mfs, err := New(&c.opts) if err != nil { - test.Assert(t, "error", c.expErr, err.Error(), true) + test.Assert(t, "error", c.expErr, err.Error()) continue } gotListNames := mfs.ListNames() - test.Assert(t, "names", c.expMapKeys, gotListNames, true) + test.Assert(t, "names", c.expMapKeys, gotListNames) } } @@ -420,7 +420,7 @@ func TestFilter(t *testing.T) { got := mfs.isIncluded(sysPath, fi.Mode()) - test.Assert(t, sysPath, c.exp[x], got, true) + test.Assert(t, sysPath, c.exp[x], got) } } } diff --git a/lib/memfs/node_test.go b/lib/memfs/node_test.go index f2f899a8..5b6375e7 100644 --- a/lib/memfs/node_test.go +++ b/lib/memfs/node_test.go @@ -57,9 +57,9 @@ func TestNode_Read(t *testing.T) { n, err := node.Read(c.p) - test.Assert(t, "p", c.exp, c.p, true) - test.Assert(t, "n", c.expN, n, true) - test.Assert(t, "error", c.expError, err, true) + test.Assert(t, "p", c.exp, c.p) + test.Assert(t, "n", c.expN, n) + test.Assert(t, "error", c.expError, err) } } @@ -92,7 +92,7 @@ func TestNode_Readdir(t *testing.T) { t.Fatal(err) } - test.Assert(t, "Readdir(0)", expFileNames, gotFileNames(fis), true) + test.Assert(t, "Readdir(0)", expFileNames, gotFileNames(fis)) // Test reading two nodes at a time. @@ -105,7 +105,7 @@ func TestNode_Readdir(t *testing.T) { allFis = append(allFis, fis...) } - test.Assert(t, "Readdir(2)", expFileNames, gotFileNames(allFis), true) + test.Assert(t, "Readdir(2)", expFileNames, gotFileNames(allFis)) } func gotFileNames(fis []os.FileInfo) (names []string) { @@ -159,7 +159,7 @@ func TestNode_Seek(t *testing.T) { got, err := node.Seek(c.offset, c.whence) - test.Assert(t, "Seek", c.exp, got, true) - test.Assert(t, "Seek error", c.expError, err, true) + test.Assert(t, "Seek", c.exp, got) + test.Assert(t, "Seek error", c.expError, err) } } |
