mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 06:16:08 +00:00
Improve a test
This commit is contained in:
parent
a1854a7614
commit
d8dd8d77d4
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user