Skip to content

Commit 4535c35

Browse files
author
Mike Atlas
committed
update tests
1 parent 6d2bd68 commit 4535c35

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

runtime/context_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ func TestAnnotateContext(t *testing.T) {
1717
if err != nil {
1818
t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", "GET", "http://localhost", err)
1919
}
20+
21+
request.RemoteAddr = "127.0.0.1"
2022
request.Header.Add("Some-Irrelevant-Header", "some value")
2123
annotated := runtime.AnnotateContext(ctx, request)
24+
ctx = metadata.NewContext(ctx, metadata.Pairs("RemoteAddr", "127.0.0.1"))
2225
if annotated != ctx {
2326
t.Errorf("AnnotateContext(ctx, request) = %v; want %v", annotated, ctx)
2427
}
@@ -29,8 +32,8 @@ func TestAnnotateContext(t *testing.T) {
2932
request.Header.Add("Authorization", "Token 1234567890")
3033
annotated = runtime.AnnotateContext(ctx, request)
3134
md, ok := metadata.FromContext(annotated)
32-
if !ok || len(md) != 3 {
33-
t.Errorf("Expected 3 metadata items in context; got %v", md)
35+
if !ok || len(md) != 4 {
36+
t.Errorf("Expected 4 metadata items in context; got %v", md)
3437
}
3538
if got, want := md["foobar"], []string{"Value1"}; !reflect.DeepEqual(got, want) {
3639
t.Errorf(`md["foobar"] = %q; want %q`, got, want)

0 commit comments

Comments
 (0)