forked from NYANDEV/forgejo
f9618b8896
defer test.MockVariable(&variable, 1234)() (cherry picked from commit 9c78752444c2411f20e72b96b7b4fdf5359099d5) (cherry picked from commit 8ab559df0d57a17a0ea73bd3676f40a523a15ab6) (cherry picked from commit 2e7fe1ec9566e4840992e4049d8349873b7334ee)
26 lines
574 B
Go
26 lines
574 B
Go
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package test
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
// RedirectURL returns the redirect URL of a http response.
|
|
func RedirectURL(resp http.ResponseWriter) string {
|
|
return resp.Header().Get("Location")
|
|
}
|
|
|
|
func IsNormalPageCompleted(s string) bool {
|
|
return strings.Contains(s, `<footer class="page-footer"`) && strings.Contains(s, `</html>`)
|
|
}
|
|
|
|
func MockVariable[T any](variable *T, mock T) func() {
|
|
original := *variable
|
|
*variable = mock
|
|
return func() {
|
|
*variable = original
|
|
}
|
|
}
|