mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 12:07:09 +00:00
fix(sidecar): synchronize health fixture writes and exercise healthError
This commit is contained in:
1 parent
a0ee66db75
commit
7fdf5c6967
1 file changed
+20
@@ -9,6 +9,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
|
||||||
driverpb "github.com/priyanshujain/sanderling/proto/driverpb"
|
driverpb "github.com/priyanshujain/sanderling/proto/driverpb"
|
||||||
)
|
)
|
||||||
@@ -180,7 +182,9 @@ func TestClient_WaitForHealth_PollsUntilReady(t *testing.T) {
|
|||||||
|
|
||||||
func TestClient_WaitForHealth_HonorsContext(t *testing.T) {
|
func TestClient_WaitForHealth_HonorsContext(t *testing.T) {
|
||||||
state := newHarness(t)
|
state := newHarness(t)
|
||||||
|
state.fake.mutex.Lock()
|
||||||
state.fake.healthReady = false
|
state.fake.healthReady = false
|
||||||
|
state.fake.mutex.Unlock()
|
||||||
client, err := Dial(state.address)
|
client, err := Dial(state.address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -195,6 +199,22 @@ func TestClient_WaitForHealth_HonorsContext(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClient_Health_SurfacesRPCError(t *testing.T) {
|
||||||
|
state := newHarness(t)
|
||||||
|
state.fake.mutex.Lock()
|
||||||
|
state.fake.healthError = status.Error(codes.Unavailable, "boom")
|
||||||
|
state.fake.mutex.Unlock()
|
||||||
|
client, err := Dial(state.address)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer client.Close()
|
||||||
|
|
||||||
|
if _, err := client.Health(context.Background()); err == nil {
|
||||||
|
t.Fatal("expected Health to surface the RPC error, got nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestClient_LaunchAndTerminate(t *testing.T) {
|
func TestClient_LaunchAndTerminate(t *testing.T) {
|
||||||
state := newHarness(t)
|
state := newHarness(t)
|
||||||
client, _ := Dial(state.address)
|
client, _ := Dial(state.address)
|
||||||
|
|||||||
Reference in new issue
Block a user