Esempio n. 1
0
func TestUseID_Reuse(t *testing.T) {
	r, _ := http.NewRequest("GET", "/foo/bar", nil)
	id := "hello"
	r.Header.Set(gourdctx.IDHeaderKey, id)
	ctx := gourdctx.UseID(context.Background(), r)

	if want, have := id, gourdctx.GetRequestID(r); want != have {
		t.Errorf("expected %#v, got %#v", want, have)
	}
	if want, have := id, gourdctx.GetID(ctx); want != have {
		t.Errorf("expected %#v, got %#v", want, have)
	}

}
Esempio n. 2
0
func TestUseID(t *testing.T) {
	r, _ := http.NewRequest("GET", "/foo/bar", nil)
	ctx := gourdctx.UseID(context.Background(), r)
	var id string

	if id = gourdctx.GetRequestID(r); id == "" {
		t.Errorf("unexpected empty string")
		return
	}

	if want, have := id, gourdctx.GetID(ctx); want != have {
		t.Errorf("expected %#v, got %#v", want, have)
	}

}