From 7b3a490010dc194a049abef5d4a9be3afb728f8d Mon Sep 17 00:00:00 2001 From: Boyan Soubachov Date: Wed, 11 Dec 2019 20:57:44 +0200 Subject: [PATCH] Rename --- assert/assertion_format.go | 36 +++++++------- assert/assertion_forward.go | 72 ++++++++++++++-------------- assert/assertions.go | 8 ++-- assert/assertions_test.go | 16 +++---- require/require.go | 96 ++++++++++++++++++------------------- require/require_forward.go | 72 ++++++++++++++-------------- 6 files changed, 150 insertions(+), 150 deletions(-) diff --git a/assert/assertion_format.go b/assert/assertion_format.go index eabfa14..8dbfc87 100644 --- a/assert/assertion_format.go +++ b/assert/assertion_format.go @@ -373,6 +373,15 @@ func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool return Nil(t, object, append([]interface{}{msg}, args...)...) } +// NoDirExistsf checks whether a directory does not exist in the given path. +// It fails if the path points to an existing _directory_ only. +func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NoDirExists(t, path, append([]interface{}{msg}, args...)...) +} + // NoErrorf asserts that a function returned no error (i.e. `nil`). // // actualObj, err := SomeFunction() @@ -386,6 +395,15 @@ func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool { return NoError(t, err, append([]interface{}{msg}, args...)...) } +// NoFileExistsf checks whether a file does not exist in a given path. It fails +// if the path points to an existing _file_ only. +func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NoFileExists(t, path, append([]interface{}{msg}, args...)...) +} + // NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // @@ -399,15 +417,6 @@ func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, a return NotContains(t, s, contains, append([]interface{}{msg}, args...)...) } -// NotDirExistsf checks whether a directory does not exist in the given path. -// It fails if the path points to an existing _directory_ only. -func NotDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotDirExists(t, path, append([]interface{}{msg}, args...)...) -} - // NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // @@ -434,15 +443,6 @@ func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...) } -// NotFileExistsf checks whether a file does not exist in a given path. It fails -// if the path points to an existing _file_ only. -func NotFileExistsf(t TestingT, path string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotFileExists(t, path, append([]interface{}{msg}, args...)...) -} - // NotNilf asserts that the specified object is not nil. // // assert.NotNilf(t, err, "error message %s", "formatted") diff --git a/assert/assertion_forward.go b/assert/assertion_forward.go index 39c2cb0..f056de6 100644 --- a/assert/assertion_forward.go +++ b/assert/assertion_forward.go @@ -735,6 +735,24 @@ func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) b return Nilf(a.t, object, msg, args...) } +// NoDirExists checks whether a directory does not exist in the given path. +// It fails if the path points to an existing _directory_ only. +func (a *Assertions) NoDirExists(path string, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NoDirExists(a.t, path, msgAndArgs...) +} + +// NoDirExistsf checks whether a directory does not exist in the given path. +// It fails if the path points to an existing _directory_ only. +func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NoDirExistsf(a.t, path, msg, args...) +} + // NoError asserts that a function returned no error (i.e. `nil`). // // actualObj, err := SomeFunction() @@ -761,6 +779,24 @@ func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool { return NoErrorf(a.t, err, msg, args...) } +// NoFileExists checks whether a file does not exist in a given path. It fails +// if the path points to an existing _file_ only. +func (a *Assertions) NoFileExists(path string, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NoFileExists(a.t, path, msgAndArgs...) +} + +// NoFileExistsf checks whether a file does not exist in a given path. It fails +// if the path points to an existing _file_ only. +func (a *Assertions) NoFileExistsf(path string, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NoFileExistsf(a.t, path, msg, args...) +} + // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // @@ -787,24 +823,6 @@ func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg strin return NotContainsf(a.t, s, contains, msg, args...) } -// NotDirExists checks whether a directory does not exist in the given path. -// It fails if the path points to an existing _directory_ only. -func (a *Assertions) NotDirExists(path string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotDirExists(a.t, path, msgAndArgs...) -} - -// NotDirExistsf checks whether a directory does not exist in the given path. -// It fails if the path points to an existing _directory_ only. -func (a *Assertions) NotDirExistsf(path string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotDirExistsf(a.t, path, msg, args...) -} - // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // @@ -857,24 +875,6 @@ func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg str return NotEqualf(a.t, expected, actual, msg, args...) } -// NotFileExists checks whether a file does not exist in a given path. It fails -// if the path points to an existing _file_ only. -func (a *Assertions) NotFileExists(path string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotFileExists(a.t, path, msgAndArgs...) -} - -// NotFileExistsf checks whether a file does not exist in a given path. It fails -// if the path points to an existing _file_ only. -func (a *Assertions) NotFileExistsf(path string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotFileExistsf(a.t, path, msg, args...) -} - // NotNil asserts that the specified object is not nil. // // a.NotNil(err) diff --git a/assert/assertions.go b/assert/assertions.go index 7965577..1bb67c1 100644 --- a/assert/assertions.go +++ b/assert/assertions.go @@ -1383,9 +1383,9 @@ func FileExists(t TestingT, path string, msgAndArgs ...interface{}) bool { return true } -// NotFileExists checks whether a file does not exist in a given path. It fails +// NoFileExists checks whether a file does not exist in a given path. It fails // if the path points to an existing _file_ only. -func NotFileExists(t TestingT, path string, msgAndArgs ...interface{}) bool { +func NoFileExists(t TestingT, path string, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() } @@ -1421,9 +1421,9 @@ func DirExists(t TestingT, path string, msgAndArgs ...interface{}) bool { return true } -// NotDirExists checks whether a directory does not exist in the given path. +// NoDirExists checks whether a directory does not exist in the given path. // It fails if the path points to an existing _directory_ only. -func NotDirExists(t TestingT, path string, msgAndArgs ...interface{}) bool { +func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() } diff --git a/assert/assertions_test.go b/assert/assertions_test.go index 1ae6273..ee241b8 100644 --- a/assert/assertions_test.go +++ b/assert/assertions_test.go @@ -1473,15 +1473,15 @@ func TestFileExists(t *testing.T) { False(t, FileExists(mockT, "../_codegen")) } -func TestNotFileExists(t *testing.T) { +func TestNoFileExists(t *testing.T) { mockT := new(testing.T) - False(t, NotFileExists(mockT, "assertions.go")) + False(t, NoFileExists(mockT, "assertions.go")) mockT = new(testing.T) - True(t, NotFileExists(mockT, "random_file")) + True(t, NoFileExists(mockT, "random_file")) mockT = new(testing.T) - True(t, NotFileExists(mockT, "../_codegen")) + True(t, NoFileExists(mockT, "../_codegen")) } func TestDirExists(t *testing.T) { @@ -1495,15 +1495,15 @@ func TestDirExists(t *testing.T) { True(t, DirExists(mockT, "../_codegen")) } -func TestNotDirExists(t *testing.T) { +func TestNoDirExists(t *testing.T) { mockT := new(testing.T) - True(t, NotDirExists(mockT, "assertions.go")) + True(t, NoDirExists(mockT, "assertions.go")) mockT = new(testing.T) - True(t, NotDirExists(mockT, "random_dir")) + True(t, NoDirExists(mockT, "random_dir")) mockT = new(testing.T) - False(t, NotDirExists(mockT, "../_codegen")) + False(t, NoDirExists(mockT, "../_codegen")) } func TestJSONEq_EqualSONString(t *testing.T) { diff --git a/require/require.go b/require/require.go index df3ebd1..521958f 100644 --- a/require/require.go +++ b/require/require.go @@ -940,6 +940,30 @@ func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) { t.FailNow() } +// NoDirExists checks whether a directory does not exist in the given path. +// It fails if the path points to an existing _directory_ only. +func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.NoDirExists(t, path, msgAndArgs...) { + return + } + t.FailNow() +} + +// NoDirExistsf checks whether a directory does not exist in the given path. +// It fails if the path points to an existing _directory_ only. +func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.NoDirExistsf(t, path, msg, args...) { + return + } + t.FailNow() +} + // NoError asserts that a function returned no error (i.e. `nil`). // // actualObj, err := SomeFunction() @@ -972,6 +996,30 @@ func NoErrorf(t TestingT, err error, msg string, args ...interface{}) { t.FailNow() } +// NoFileExists checks whether a file does not exist in a given path. It fails +// if the path points to an existing _file_ only. +func NoFileExists(t TestingT, path string, msgAndArgs ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.NoFileExists(t, path, msgAndArgs...) { + return + } + t.FailNow() +} + +// NoFileExistsf checks whether a file does not exist in a given path. It fails +// if the path points to an existing _file_ only. +func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.NoFileExistsf(t, path, msg, args...) { + return + } + t.FailNow() +} + // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // @@ -1004,30 +1052,6 @@ func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, a t.FailNow() } -// NotDirExists checks whether a directory does not exist in the given path. -// It fails if the path points to an existing _directory_ only. -func NotDirExists(t TestingT, path string, msgAndArgs ...interface{}) { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if assert.NotDirExists(t, path, msgAndArgs...) { - return - } - t.FailNow() -} - -// NotDirExistsf checks whether a directory does not exist in the given path. -// It fails if the path points to an existing _directory_ only. -func NotDirExistsf(t TestingT, path string, msg string, args ...interface{}) { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if assert.NotDirExistsf(t, path, msg, args...) { - return - } - t.FailNow() -} - // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // @@ -1092,30 +1116,6 @@ func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, t.FailNow() } -// NotFileExists checks whether a file does not exist in a given path. It fails -// if the path points to an existing _file_ only. -func NotFileExists(t TestingT, path string, msgAndArgs ...interface{}) { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if assert.NotFileExists(t, path, msgAndArgs...) { - return - } - t.FailNow() -} - -// NotFileExistsf checks whether a file does not exist in a given path. It fails -// if the path points to an existing _file_ only. -func NotFileExistsf(t TestingT, path string, msg string, args ...interface{}) { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if assert.NotFileExistsf(t, path, msg, args...) { - return - } - t.FailNow() -} - // NotNil asserts that the specified object is not nil. // // assert.NotNil(t, err) diff --git a/require/require_forward.go b/require/require_forward.go index 9d2bc53..57681d1 100644 --- a/require/require_forward.go +++ b/require/require_forward.go @@ -736,6 +736,24 @@ func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) { Nilf(a.t, object, msg, args...) } +// NoDirExists checks whether a directory does not exist in the given path. +// It fails if the path points to an existing _directory_ only. +func (a *Assertions) NoDirExists(path string, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NoDirExists(a.t, path, msgAndArgs...) +} + +// NoDirExistsf checks whether a directory does not exist in the given path. +// It fails if the path points to an existing _directory_ only. +func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NoDirExistsf(a.t, path, msg, args...) +} + // NoError asserts that a function returned no error (i.e. `nil`). // // actualObj, err := SomeFunction() @@ -762,6 +780,24 @@ func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) { NoErrorf(a.t, err, msg, args...) } +// NoFileExists checks whether a file does not exist in a given path. It fails +// if the path points to an existing _file_ only. +func (a *Assertions) NoFileExists(path string, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NoFileExists(a.t, path, msgAndArgs...) +} + +// NoFileExistsf checks whether a file does not exist in a given path. It fails +// if the path points to an existing _file_ only. +func (a *Assertions) NoFileExistsf(path string, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NoFileExistsf(a.t, path, msg, args...) +} + // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // @@ -788,24 +824,6 @@ func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg strin NotContainsf(a.t, s, contains, msg, args...) } -// NotDirExists checks whether a directory does not exist in the given path. -// It fails if the path points to an existing _directory_ only. -func (a *Assertions) NotDirExists(path string, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotDirExists(a.t, path, msgAndArgs...) -} - -// NotDirExistsf checks whether a directory does not exist in the given path. -// It fails if the path points to an existing _directory_ only. -func (a *Assertions) NotDirExistsf(path string, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotDirExistsf(a.t, path, msg, args...) -} - // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // @@ -858,24 +876,6 @@ func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg str NotEqualf(a.t, expected, actual, msg, args...) } -// NotFileExists checks whether a file does not exist in a given path. It fails -// if the path points to an existing _file_ only. -func (a *Assertions) NotFileExists(path string, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotFileExists(a.t, path, msgAndArgs...) -} - -// NotFileExistsf checks whether a file does not exist in a given path. It fails -// if the path points to an existing _file_ only. -func (a *Assertions) NotFileExistsf(path string, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotFileExistsf(a.t, path, msg, args...) -} - // NotNil asserts that the specified object is not nil. // // a.NotNil(err)