2017-12-15 16:11:02 -05:00
|
|
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2017-12-15 16:11:02 -05:00
|
|
|
|
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2023-05-29 11:00:21 -04:00
|
|
|
"strings"
|
2017-12-15 16:11:02 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// RedirectURL returns the redirect URL of a http response.
|
|
|
|
func RedirectURL(resp http.ResponseWriter) string {
|
|
|
|
return resp.Header().Get("Location")
|
|
|
|
}
|
2023-05-29 11:00:21 -04:00
|
|
|
|
|
|
|
func IsNormalPageCompleted(s string) bool {
|
|
|
|
return strings.Contains(s, `<footer class="page-footer"`) && strings.Contains(s, `</html>`)
|
|
|
|
}
|
2023-06-30 19:20:44 -04:00
|
|
|
|
|
|
|
func MockVariable[T any](variable *T, mock T) func() {
|
|
|
|
original := *variable
|
|
|
|
*variable = mock
|
|
|
|
return func() {
|
|
|
|
*variable = original
|
|
|
|
}
|
|
|
|
}
|