mattermost/server/channels/store/errors_test.go
Ben Schumacher 09c39cf3ec
[MM-58020] Improve error message of NotFound errors in store (#26870)
* Improve error message of NotFound errors in store

* update mmctl tests
2024-05-07 15:30:48 +02:00

28 lines
699 B
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package store
import (
"errors"
"testing"
"github.com/mattermost/mattermost/server/public/model"
"github.com/stretchr/testify/assert"
)
func TestErrNotFound(t *testing.T) {
id := model.NewId()
t.Run("plain", func(t *testing.T) {
err := NewErrNotFound("channel", id)
assert.EqualError(t, err, "resource \"channel\" not found, id: "+id)
})
t.Run("with wrapped error", func(t *testing.T) {
err := NewErrNotFound("channel", id)
err = err.Wrap(errors.New("some error"))
assert.EqualError(t, err, "resource \"channel\" not found, id: "+id+", error: some error")
})
}