mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-22 02:47:48 +08:00
29 lines
565 B
Go
29 lines
565 B
Go
package util
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
|
|
)
|
|
|
|
func TestLogErrorDoesNotBlockWhenCtxIsNotSetUpForLogging(t *testing.T) {
|
|
ctx := context.Background()
|
|
LogError(ctx, errors.New("ignore me"))
|
|
}
|
|
|
|
func TestLogErrorReceivedByParent(t *testing.T) {
|
|
|
|
expected := errors.New("From child to parent")
|
|
|
|
ctx, errs := ContextWithErrorLog(context.Background())
|
|
|
|
go func() {
|
|
LogError(ctx, expected)
|
|
}()
|
|
|
|
if err := <-errs; err != expected {
|
|
t.Fatal("didn't receive the expected error")
|
|
}
|
|
}
|