Update type assertion logic

Logic updated to evaluate with a boolean after the type assertion.
This allows us to check if the type assertion succeeded and be
more clear with errors.
This commit is contained in:
Sarah Christoff 2019-05-17 13:32:36 -05:00
parent 2052307c1c
commit 1ee6dd253b
1 changed files with 8 additions and 3 deletions

View File

@ -85,9 +85,14 @@ func TestCoordinate_Nodes(t *testing.T) {
t.Fatalf("err: %v", err)
}
coordinates := obj.(structs.Coordinates)
if coordinates == nil || len(coordinates) != 0 {
t.Fatalf("bad: %v", coordinates)
// Check that coordinates are empty before registering a node
coordinates, ok := obj.(structs.Coordinates)
if !ok {
t.Fatalf("expected: structs.Coordinates, received: %v", coordinates)
}
if len(coordinates) != 0 {
t.Fatalf("coordinates should be empty, received: %v", coordinates)
}
// Register the nodes.