This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
2017-03-30 15:36:04 +02:00
|
|
|
package log
|
2017-03-30 14:49:14 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
2017-03-30 17:02:20 +02:00
|
|
|
|
2017-03-30 14:49:14 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLog(t *testing.T) {
|
|
|
|
assertion := assert.New(t)
|
2017-03-30 17:02:20 +02:00
|
|
|
|
2017-03-30 14:49:14 +02:00
|
|
|
req, _ := http.NewRequest("GET", "https://google.com/lola/duda?q=wasd", nil)
|
2017-03-30 15:36:04 +02:00
|
|
|
log := HTTP(req)
|
2017-03-30 14:49:14 +02:00
|
|
|
_, ok := log.Data["remote"]
|
2017-03-30 17:02:20 +02:00
|
|
|
|
|
|
|
assertion.NotNil(ok, "remote address not set in logger")
|
2017-03-30 14:49:14 +02:00
|
|
|
assertion.Equal("GET", log.Data["method"], "method not set in logger")
|
|
|
|
assertion.Equal("/lola/duda?q=wasd", log.Data["url"], "path not set in logger")
|
|
|
|
}
|