Improve a test

This commit is contained in:
Derek Chiang 2015-04-16 17:08:56 -04:00 committed by James Phillips
parent a1854a7614
commit d8dd8d77d4

View File

@ -1,7 +1,6 @@
package consul
import (
"fmt"
"math/rand"
"os"
"testing"
@ -39,11 +38,10 @@ func coordinatesEqual(a, b *coordinate.Coordinate) bool {
if err != nil {
panic(err)
}
fmt.Printf("dist: %v", dist)
return dist < 0.1
}
func TestCoordinate_Update(t *testing.T) {
func TestCoordinate(t *testing.T) {
dir1, s1 := testServer(t)
defer os.RemoveAll(dir1)
defer s1.Shutdown()
@ -88,4 +86,17 @@ func TestCoordinate_Update(t *testing.T) {
if !coordinatesEqual(out2.Coord, arg.Coord) {
t.Fatalf("should be equal\n%v\n%v", out2.Coord, arg.Coord)
}
// Now let's override the original coordinate; Coordinate.Get should return
// the latest coordinate
arg.Coord = getRandomCoordinate()
if err := client.Call("Coordinate.Update", &arg, &out); err != nil {
t.Fatalf("err: %v", err)
}
if err := client.Call("Coordinate.Get", &arg2, &out2); err != nil {
t.Fatalf("err: %v", err)
}
if !coordinatesEqual(out2.Coord, arg.Coord) {
t.Fatalf("should be equal\n%v\n%v", out2.Coord, arg.Coord)
}
}