forked from kubernetes-sigs/cluster-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kubernetes-sigs#9265 from Nordix/resolve-releases/…
…adil ✨ Resolve release markers
- Loading branch information
Showing
10 changed files
with
354 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package test contains test util functions for goproxy. | ||
package test | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"net/url" | ||
"testing" | ||
) | ||
|
||
// NewFakeGoproxy sets up a test HTTP server along with a github.Client that is | ||
// configured to talk to that test server. Tests should register handlers on | ||
// mux which provide mock responses for the API method being tested. | ||
func NewFakeGoproxy() (scheme string, host string, mux *http.ServeMux, teardown func()) { | ||
// mux is the HTTP request multiplexer used with the test server. | ||
mux = http.NewServeMux() | ||
|
||
apiHandler := http.NewServeMux() | ||
apiHandler.Handle("/", mux) | ||
|
||
// server is a test HTTP server used to provide mock API responses. | ||
server := httptest.NewServer(apiHandler) | ||
|
||
// client is the GitHub client being tested and is configured to use test server. | ||
url, _ := url.Parse(server.URL + "/") | ||
return url.Scheme, url.Host, mux, server.Close | ||
} | ||
|
||
// HTTPTestMethod reports error http.Request does not return want string. | ||
func HTTPTestMethod(t *testing.T, r *http.Request, want string) { | ||
t.Helper() | ||
|
||
if got := r.Method; got != want { | ||
t.Errorf("Request method: %v, want %v", got, want) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.