Files
EdgeNode/internal/caches/errros_test.go

26 lines
870 B
Go
Raw Permalink Normal View History

2024-05-17 18:30:33 +08:00
// Copyright 2021 GoEdge goedge.cdn@gmail.com. All rights reserved.
2021-06-08 11:24:41 +08:00
2024-01-15 21:00:20 +08:00
package caches_test
2021-06-08 11:24:41 +08:00
import (
2024-01-15 21:00:20 +08:00
"errors"
"fmt"
2024-07-27 15:42:50 +08:00
"testing"
2024-01-15 21:00:20 +08:00
"github.com/TeaOSLab/EdgeNode/internal/caches"
2021-06-08 11:24:41 +08:00
"github.com/iwind/TeaGo/assert"
)
func TestCanIgnoreErr(t *testing.T) {
2024-01-15 21:00:20 +08:00
var a = assert.NewAssertion(t)
2021-06-08 11:24:41 +08:00
2024-01-15 21:00:20 +08:00
a.IsTrue(caches.CanIgnoreErr(caches.ErrFileIsWriting))
a.IsTrue(caches.CanIgnoreErr(fmt.Errorf("error: %w", caches.ErrFileIsWriting)))
a.IsTrue(errors.Is(fmt.Errorf("error: %w", caches.ErrFileIsWriting), caches.ErrFileIsWriting))
a.IsTrue(errors.Is(caches.ErrFileIsWriting, caches.ErrFileIsWriting))
a.IsTrue(caches.CanIgnoreErr(caches.NewCapacityError("over capacity")))
a.IsTrue(caches.CanIgnoreErr(fmt.Errorf("error: %w", caches.NewCapacityError("over capacity"))))
a.IsFalse(caches.CanIgnoreErr(caches.ErrNotFound))
a.IsFalse(caches.CanIgnoreErr(errors.New("test error")))
2021-06-08 11:24:41 +08:00
}