mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-15 11:13:37 +08:00

This commit... is a second attempt at: https://github.com/jbenet/go-ipfs/pull/68 partially addresses: https://github.com/jbenet/go-ipfs/issues/66 is the result of discussion at: https://gist.github.com/perfmode/f2951c1ed3a02c484d0b
29 lines
576 B
Go
29 lines
576 B
Go
package util
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/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")
|
|
}
|
|
}
|