github.com/oinume/lekcije@v0.0.0-20231017100347-5b4c5eb6ab24/backend/interface/http/oauth_test.go (about)

     1  package http
     2  
     3  // TODO: rewrite test
     4  //func TestOAuth(t *testing.T) {
     5  //	t.Parallel()
     6  //	a := assert.New(t)
     7  //	r := require.New(t)
     8  //	s := newTestServer(t, nil)
     9  //
    10  //	testCases := []struct {
    11  //		path        string
    12  //		handler     http.HandlerFunc
    13  //		code        int
    14  //		headerNames []string
    15  //	}{
    16  //		{
    17  //			path:    "/",
    18  //			handler: s.oauthGoogleHandler(),
    19  //			code:    http.StatusFound,
    20  //			headerNames: []string{
    21  //				"Set-Cookie",
    22  //				"Location",
    23  //			},
    24  //		},
    25  //	}
    26  //
    27  //	for _, tc := range testCases {
    28  //		req, err := http.NewRequest("GET", tc.path, nil)
    29  //		r.NoError(err)
    30  //
    31  //		ctx := context_data.SetTrackingID(req.Context(), "a")
    32  //		req = req.WithContext(ctx)
    33  //
    34  //		w := httptest.NewRecorder()
    35  //		tc.handler.ServeHTTP(w, req)
    36  //
    37  //		a.Equal(tc.code, w.Code)
    38  //		for _, header := range tc.headerNames {
    39  //			if w.Header().Get(header) == "" {
    40  //				a.Failf("No header: %v", header)
    41  //			}
    42  //		}
    43  //	}
    44  //}