package gitea_test import ( "context" "net/http" "net/http/httptest" "testing" "gitea.d-ma.be/mathias/gitea-mcp/internal/gitea" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestClientGetsTokenInHeader(t *testing.T) { var gotAuth string srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { gotAuth = r.Header.Get("Authorization") w.Header().Set("Content-Type", "application/json") _, _ = w.Write([]byte(`{"ok":true}`)) })) defer srv.Close() c := gitea.NewClient(srv.URL, "test-token") body, status, err := c.GetJSON(context.Background(), "/api/v1/user") require.NoError(t, err) assert.Equal(t, 200, status) assert.Contains(t, string(body), `"ok":true`) assert.Equal(t, "token test-token", gotAuth) }