mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2024-12-22 12:08:00 +00:00
refactor on some tests
This commit is contained in:
parent
def2b0f2f0
commit
9b10052cd1
@ -19,7 +19,7 @@ import (
|
|||||||
|
|
||||||
func buildContainer() testcontainers.ContainerRequest {
|
func buildContainer() testcontainers.ContainerRequest {
|
||||||
_, filename, _, _ := runtime.Caller(0)
|
_, filename, _, _ := runtime.Caller(0)
|
||||||
dirname := filepath.Dir(filename)
|
dir := filepath.Dir(filename)
|
||||||
|
|
||||||
req := testcontainers.ContainerRequest{
|
req := testcontainers.ContainerRequest{
|
||||||
FromDockerfile: testcontainers.FromDockerfile{
|
FromDockerfile: testcontainers.FromDockerfile{
|
||||||
@ -38,10 +38,10 @@ func buildContainer() testcontainers.ContainerRequest {
|
|||||||
ExposedPorts: []string{"8000:8000", "8001:8001"},
|
ExposedPorts: []string{"8000:8000", "8001:8001"},
|
||||||
WaitingFor: wait.ForLog("Starting TLS server listening on :8001"),
|
WaitingFor: wait.ForLog("Starting TLS server listening on :8001"),
|
||||||
BindMounts: map[string]string{
|
BindMounts: map[string]string{
|
||||||
"/tmp/GeoIP2-City-Test.mmdb": filepath.Join(dirname, "/../test/GeoIP2-City-Test.mmdb"),
|
"/tmp/GeoIP2-City-Test.mmdb": filepath.Join(dir, "/../test/GeoIP2-City-Test.mmdb"),
|
||||||
"/tmp/GeoLite2-ASN-Test.mmdb": filepath.Join(dirname, "/../test/GeoLite2-ASN-Test.mmdb"),
|
"/tmp/GeoLite2-ASN-Test.mmdb": filepath.Join(dir, "/../test/GeoLite2-ASN-Test.mmdb"),
|
||||||
"/tmp/server.pem": filepath.Join(dirname, "/../test/server.pem"),
|
"/tmp/server.pem": filepath.Join(dir, "/../test/server.pem"),
|
||||||
"/tmp/server.key": filepath.Join(dirname, "/../test/server.key"),
|
"/tmp/server.key": filepath.Join(dir, "/../test/server.key"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,11 @@ Host:
|
|||||||
`
|
`
|
||||||
|
|
||||||
req, _ := http.NewRequest("GET", "/headers", nil)
|
req, _ := http.NewRequest("GET", "/headers", nil)
|
||||||
req.Header["Header1"] = []string{"value1"}
|
req.Header = map[string][]string{
|
||||||
req.Header["Header2"] = []string{"value21", "value22"}
|
"Header1": {"value1"},
|
||||||
req.Header["Header3"] = []string{"value3"}
|
"Header2": {"value21", "value22"},
|
||||||
|
"Header3": {"value3"},
|
||||||
|
}
|
||||||
|
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
app.ServeHTTP(w, req)
|
app.ServeHTTP(w, req)
|
||||||
|
@ -54,10 +54,11 @@ const expectedHome = `
|
|||||||
|
|
||||||
func TestDefaultTemplate(t *testing.T) {
|
func TestDefaultTemplate(t *testing.T) {
|
||||||
req, _ := http.NewRequest("GET", "/", nil)
|
req, _ := http.NewRequest("GET", "/", nil)
|
||||||
|
req.Header = map[string][]string{
|
||||||
req.Header["Header1"] = []string{"value1"}
|
"Header1": {"value1"},
|
||||||
req.Header["Header2"] = []string{"value21", "value22"}
|
"Header2": {"value21", "value22"},
|
||||||
req.Header["Header3"] = []string{"value3"}
|
"Header3": {"value3"},
|
||||||
|
}
|
||||||
|
|
||||||
tmpl, _ := template.New("home").Parse(home)
|
tmpl, _ := template.New("home").Parse(home)
|
||||||
response := JSONResponse{
|
response := JSONResponse{
|
||||||
|
Loading…
Reference in New Issue
Block a user