Skip to content

Commit

Permalink
Prevent panic in tests whose queries fail
Browse files Browse the repository at this point in the history
Some tests were ignoring errors and proceeding to inspect query
results, causing failure via panic. Instead, fail these tests via more
explicit assertions.
  • Loading branch information
seh committed Jan 11, 2017
1 parent 35239a9 commit d765ac6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/net_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ func TestConnectionCreation(t *testing.T) {
e := fargo.NewConnFromConfig(cfg)
apps, err := e.GetApps()
So(err, ShouldBeNil)
So(len(apps["EUREKA"].Instances), ShouldEqual, 2)
app := apps["EUREKA"]
So(app, ShouldNotBeNil)
So(len(app.Instances), ShouldEqual, 2)
})
}

Expand All @@ -46,11 +48,15 @@ func TestGetApps(t *testing.T) {
for _, j := range []bool{false, true} {
e.UseJson = j
Convey("Pull applications", t, func() {
a, _ := e.GetApps()
So(len(a["EUREKA"].Instances), ShouldEqual, 2)
apps, err := e.GetApps()
So(err, ShouldBeNil)
app := apps["EUREKA"]
So(app, ShouldNotBeNil)
So(len(app.Instances), ShouldEqual, 2)
})
Convey("Pull single application", t, func() {
a, _ := e.GetApp("EUREKA")
So(a, ShouldNotBeNil)
So(len(a.Instances), ShouldEqual, 2)
for _, ins := range a.Instances {
So(ins.IPAddr, ShouldBeIn, []string{"172.17.0.2", "172.17.0.3"})
Expand Down

0 comments on commit d765ac6

Please sign in to comment.