github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/util/context_test.go (about) 1 package util 2 3 import ( 4 "errors" 5 "testing" 6 7 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" 8 ) 9 10 func TestLogErrorDoesNotBlockWhenCtxIsNotSetUpForLogging(t *testing.T) { 11 ctx := context.Background() 12 LogError(ctx, errors.New("ignore me")) 13 } 14 15 func TestLogErrorReceivedByParent(t *testing.T) { 16 17 expected := errors.New("From child to parent") 18 19 ctx, errs := ContextWithErrorLog(context.Background()) 20 21 go func() { 22 LogError(ctx, expected) 23 }() 24 25 if err := <-errs; err != expected { 26 t.Fatal("didn't receive the expected error") 27 } 28 }