Skip to content

Commit 44b12bd

Browse files
authored
Merge pull request #248 from signalfx/remove_juju
Remove juju/errors dependency
2 parents e9e3ac4 + 792f040 commit 44b12bd

File tree

5 files changed

+61
-40
lines changed

5 files changed

+61
-40
lines changed

disco/disco_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ func testAdvertise(t *testing.T, zkConnFunc ZkConnCreatorFunc, zkConnFunc2 ZkCon
287287
require.NotNil(t, d1)
288288
defer d1.Close()
289289

290+
err = d1.refreshAll()
291+
require.NoError(t, err)
292+
290293
service, err := d1.Services("TestAdvertiseService")
291294
require.NoError(t, err)
292295
require.Equal(t, 0, len(service.ServiceInstances()))

errors/compatibility_test.go

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,61 @@ package errors
22

33
import (
44
"errors"
5+
"fmt"
56
"testing"
67

78
dropboxerrors "github.com/dropbox/godropbox/errors"
89
facebookerrors "github.com/facebookgo/stackerr"
9-
jujuerrors "github.com/juju/errors"
1010
. "github.com/smartystreets/goconvey/convey"
1111
)
1212

13+
type causableImplError struct {
14+
root error
15+
cause error
16+
}
17+
18+
func (e causableImplError) Error() string {
19+
return fmt.Sprintf("%v\n\tcause:%v", e.root, e.cause)
20+
}
21+
22+
func (e causableImplError) Cause() error {
23+
return e.cause
24+
}
25+
26+
type messageImplError struct {
27+
root error
28+
message string
29+
}
30+
31+
func (e messageImplError) Error() string {
32+
return fmt.Sprintf("%v\n\tcause:%v", e.root, e.message)
33+
}
34+
35+
func (e messageImplError) Message() string {
36+
return e.message
37+
}
38+
39+
func TestMessageErrors(t *testing.T) {
40+
Convey("When the original error implements hasMessage", t, func() {
41+
err := messageImplError{
42+
root: errors.New("foo"),
43+
message: "bar",
44+
}
45+
So(Message(err), ShouldEqual, "bar")
46+
})
47+
}
48+
49+
func TestCausableErrors(t *testing.T) {
50+
Convey("When the original error implements causableError", t, func() {
51+
cause := errors.New("cause")
52+
err := causableImplError{
53+
root: errors.New("foo"),
54+
cause: cause,
55+
}
56+
So(Cause(err), ShouldEqual, cause)
57+
})
58+
}
59+
1360
func TestGoDropbox(t *testing.T) {
1461
Convey("When the original error is godropbox", t, func() {
1562
root := dropboxerrors.New("dropbox root error")
@@ -34,21 +81,6 @@ func TestGoDropbox(t *testing.T) {
3481
})
3582
}
3683

37-
func TestJujuErrors(t *testing.T) {
38-
Convey("When the original error is jujuerror", t, func() {
39-
root := jujuerrors.New("juju root error")
40-
So(Tail(root), ShouldBeNil)
41-
dropboxWrap := jujuerrors.Annotate(root, "Wrapped error")
42-
So(Tail(dropboxWrap), ShouldEqual, root)
43-
myAnnotation := Annotate(dropboxWrap, "I have annotated juju error")
44-
So(Tail(myAnnotation), ShouldEqual, root)
45-
So(Cause(myAnnotation), ShouldEqual, root)
46-
So(Details(myAnnotation), ShouldContainSubstring, "juju root error")
47-
So(Details(myAnnotation), ShouldContainSubstring, "I have annotated juju error")
48-
So(jujuerrors.Cause(myAnnotation), ShouldEqual, Tail(myAnnotation))
49-
})
50-
}
51-
5284
func TestFacebookErrors(t *testing.T) {
5385
Convey("When the original error is fb", t, func() {
5486
root := facebookerrors.New("fb root error")

go.mod

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ require (
1010
github.com/go-stack/stack v1.8.1
1111
github.com/gogo/protobuf v1.3.2
1212
github.com/jaegertracing/jaeger v1.38.0
13-
github.com/juju/errors v0.0.0-20181012004132-a4583d0a56ea
1413
github.com/mailru/easyjson v0.7.7
1514
github.com/opentracing/opentracing-go v1.2.0
1615
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
@@ -34,8 +33,6 @@ require (
3433
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
3534
github.com/josharian/intern v1.0.0 // indirect
3635
github.com/jtolds/gls v4.20.0+incompatible // indirect
37-
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect
38-
github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b // indirect
3936
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
4037
github.com/pmezard/go-difflib v1.0.0 // indirect
4138
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
@@ -53,6 +50,5 @@ require (
5350
golang.org/x/text v0.7.0 // indirect
5451
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
5552
google.golang.org/protobuf v1.28.1 // indirect
56-
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
5753
gopkg.in/yaml.v3 v3.0.1 // indirect
5854
)

go.sum

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
7474
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
7575
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
7676
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
77-
github.com/juju/errors v0.0.0-20181012004132-a4583d0a56ea h1:g2k+8WR7cHch4g0tBDhfiEvAp7fXxTNBiD1oC1Oxj3E=
78-
github.com/juju/errors v0.0.0-20181012004132-a4583d0a56ea/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q=
79-
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 h1:UUHMLvzt/31azWTN/ifGWef4WUqvXk0iRqdhdy/2uzI=
80-
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U=
81-
github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b h1:Rrp0ByJXEjhREMPGTt3aWYjoIsUGCbt21ekbeJcTWv0=
82-
github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA=
8377
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
8478
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
8579
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
@@ -243,11 +237,8 @@ google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175
243237
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
244238
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
245239
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
246-
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw=
247-
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
248240
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
249241
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
250-
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
251242
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
252243
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
253244
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

sfxclient/multitokensink_test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"testing"
1111
"time"
1212

13-
"github.com/juju/errors"
1413
"github.com/signalfx/golib/v3/datapoint"
1514
"github.com/signalfx/golib/v3/event"
1615
"github.com/signalfx/golib/v3/log"
@@ -41,9 +40,9 @@ func TestAddDataToAsyncMultitokenSink(t *testing.T) {
4140
spans := GoSpanSource.Spans()
4241

4342
Convey("shouldn't accept dps and events with a context if a token isn't provided in the context", func() {
44-
So(errors.Details(s.AddEvents(ctx, evs)), ShouldContainSubstring, "no value was found on the context with key")
45-
So(errors.Details(s.AddDatapoints(ctx, dps)), ShouldContainSubstring, "no value was found on the context with key")
46-
So(errors.Details(s.AddSpans(ctx, spans)), ShouldContainSubstring, "no value was found on the context with key")
43+
So(s.AddEvents(ctx, evs).Error(), ShouldContainSubstring, "no value was found on the context with key")
44+
So(s.AddDatapoints(ctx, dps).Error(), ShouldContainSubstring, "no value was found on the context with key")
45+
So(s.AddSpans(ctx, spans).Error(), ShouldContainSubstring, "no value was found on the context with key")
4746
})
4847

4948
Convey("shouldn't accept dps and events if the sink has started, but the workers have shutdown", func() {
@@ -52,10 +51,10 @@ func TestAddDataToAsyncMultitokenSink(t *testing.T) {
5251
So(s.Close(), ShouldBeNil)
5352
_ = s.AddEvents(ctx, evs)
5453
_ = s.AddDatapointsWithToken("HELLOOOOOO", dps)
55-
So(errors.Details(s.AddEvents(ctx, evs)), ShouldContainSubstring, "unable to add events: the worker has been stopped")
56-
So(errors.Details(s.AddDatapoints(ctx, dps)), ShouldContainSubstring, "unable to add datapoints: the worker has been stopped")
57-
So(errors.Details(s.AddEventsWithToken("HELLOOOOO", evs)), ShouldContainSubstring, "unable to add events: the worker has been stopped")
58-
So(errors.Details(s.AddDatapointsWithToken("HELLOOOOOO", dps)), ShouldContainSubstring, "unable to add datapoints: the worker has been stopped")
54+
So(s.AddEvents(ctx, evs).Error(), ShouldContainSubstring, "unable to add events: the worker has been stopped")
55+
So(s.AddDatapoints(ctx, dps).Error(), ShouldContainSubstring, "unable to add datapoints: the worker has been stopped")
56+
So(s.AddEventsWithToken("HELLOOOOO", evs).Error(), ShouldContainSubstring, "unable to add events: the worker has been stopped")
57+
So(s.AddDatapointsWithToken("HELLOOOOOO", dps).Error(), ShouldContainSubstring, "unable to add datapoints: the worker has been stopped")
5958
})
6059
})
6160
}
@@ -282,7 +281,7 @@ func TestAsyncMultiTokenSinkShutdownDroppedDatapoints(t *testing.T) {
282281
for atomic.LoadInt64(&s.dpBuffered) <= int64(iterations) {
283282
runtime.Gosched()
284283
}
285-
So(errors.Details(s.Close()), ShouldContainSubstring, "may have been dropped")
284+
So(s.Close().Error(), ShouldContainSubstring, "may have been dropped")
286285
})
287286
})
288287
}
@@ -313,7 +312,7 @@ func TestAsyncMultiTokenSinkShutdownDroppedEvents(t *testing.T) {
313312
for atomic.LoadInt64(&s.evBuffered) <= int64(iterations) {
314313
runtime.Gosched()
315314
}
316-
So(errors.Details(s.Close()), ShouldContainSubstring, "may have been dropped")
315+
So(s.Close().Error(), ShouldContainSubstring, "may have been dropped")
317316
})
318317
})
319318
}
@@ -344,7 +343,7 @@ func TestAsyncMultiTokenSinkShutdownDroppedSpans(t *testing.T) {
344343
for atomic.LoadInt64(&s.spansBuffered) <= int64(iterations) {
345344
runtime.Gosched()
346345
}
347-
So(errors.Details(s.Close()), ShouldContainSubstring, "may have been dropped")
346+
So(s.Close().Error(), ShouldContainSubstring, "may have been dropped")
348347
})
349348
})
350349
}

0 commit comments

Comments
 (0)