Replacing {require,assert}.{Nil,NotNil} with {require,assert}.{NoError,Error} in the store tests (when comparing errors) (#16886)
* Replacing require.Nil with require.NoError * More replacements * More Nil/NotNill to NoError/Error * Other detected errors * renaming apperr to err * Removed not needed line * Rename old appErr variables that are no longer model.AppError values * Fixing tiny typo * Reverting changes outside the store (accidentally added) * Apply suggestions from code review Co-authored-by: Doug Lauder <wiggin77@warpmail.net> Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5f043b0a08
Коммит
0e9ad9f7f8
@@ -26,11 +26,11 @@ func testCommandWebhookStore(t *testing.T, ss store.Store) {
|
||||
h1.UserId = model.NewId()
|
||||
h1.ChannelId = model.NewId()
|
||||
h1, err := cws.Save(h1)
|
||||
require.Nil(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
var r1 *model.CommandWebhook
|
||||
r1, nErr := cws.Get(h1.Id)
|
||||
require.Nil(t, nErr)
|
||||
require.NoError(t, nErr)
|
||||
assert.Equal(t, *r1, *h1, "invalid returned webhook")
|
||||
|
||||
_, nErr = cws.Get("123")
|
||||
@@ -43,25 +43,25 @@ func testCommandWebhookStore(t *testing.T, ss store.Store) {
|
||||
h2.UserId = model.NewId()
|
||||
h2.ChannelId = model.NewId()
|
||||
h2, err = cws.Save(h2)
|
||||
require.Nil(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, nErr = cws.Get(h2.Id)
|
||||
require.NotNil(t, nErr, "Should have set the status as not found for expired webhook")
|
||||
require.Error(t, nErr, "Should have set the status as not found for expired webhook")
|
||||
require.True(t, errors.As(nErr, &nfErr), "Should have set the status as not found for expired webhook")
|
||||
|
||||
cws.Cleanup()
|
||||
|
||||
_, nErr = cws.Get(h1.Id)
|
||||
require.Nil(t, nErr, "Should have no error getting unexpired webhook")
|
||||
require.NoError(t, nErr, "Should have no error getting unexpired webhook")
|
||||
|
||||
_, nErr = cws.Get(h2.Id)
|
||||
require.True(t, errors.As(nErr, &nfErr), "Should have set the status as not found for expired webhook")
|
||||
|
||||
nErr = cws.TryUse(h1.Id, 1)
|
||||
require.Nil(t, nErr, "Should be able to use webhook once")
|
||||
require.NoError(t, nErr, "Should be able to use webhook once")
|
||||
|
||||
nErr = cws.TryUse(h1.Id, 1)
|
||||
require.NotNil(t, nErr, "Should be able to use webhook once")
|
||||
require.Error(t, nErr, "Should be able to use webhook once")
|
||||
var invErr *store.ErrInvalidInput
|
||||
require.True(t, errors.As(nErr, &invErr), "Should be able to use webhook once")
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user