genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0
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.
hs_monolith/lib/log_test.go

23 lines
546 B
Go
Raw Normal View History

2017-03-30 14:34:14 +02:00
package lib
import (
2017-03-30 14:40:17 +02:00
"testing"
2017-03-30 14:34:14 +02:00
"github.com/stretchr/testify/assert"
2017-03-30 14:40:17 +02:00
)
2017-03-30 14:34:14 +02:00
func TestLog(t *testing.T) {
2017-03-30 14:40:17 +02:00
assertion = assert.New(t)
2017-03-30 14:34:14 +02:00
2017-03-30 14:40:17 +02:00
// No values check, just if it crashed or not
LogTimestamp(false)
2017-03-30 14:34:14 +02:00
2017-03-30 14:40:17 +02:00
req, _ := http.NewRequest("GET", "https://google.com/lola/duda?q=wasd")
log := LogHTTP(req)
_, ok := log.Data["remote"]
2017-03-30 14:34:14 +02:00
2017-03-30 14:40:17 +02:00
assertion.NotNil(ok, "remote address not set in logger")
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")
2017-03-30 14:34:14 +02:00
}