2017-05-03 07:16:45 +02:00
|
|
|
// Package that provides the functionality to start und initialize the logger
|
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"
|
|
|
|
)
|
|
|
|
|
2017-04-28 10:14:59 +02:00
|
|
|
// Function to test the logging
|
2017-03-30 14:49:14 +02:00
|
|
|
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")
|
|
|
|
}
|