Files
fn-serverless/api/agent/syslog_test.go
Peter Jausovec 35408ac949 Change the syslog format to use app_name instead of app_id (#1166)
* Add AppName to the models.Call, so we can include it in the syslog

* Replace the app_id with app_name
2018-08-09 12:06:19 -07:00

30 lines
627 B
Go

package agent
import (
"bytes"
"log/syslog"
"testing"
"time"
)
func TestSyslogFormat(t *testing.T) {
var b1 bytes.Buffer
var b2 bytes.Buffer
call := "12345"
fn := "yo/dawg"
appName := "myapp"
now := time.Date(1982, 6, 25, 12, 0, 0, 0, time.UTC)
clock := func() time.Time { return now }
writer := newSyslogWriter(call, fn, appName, syslog.LOG_ERR, &nopCloser{&b1}, &b2)
writer.clock = clock
writer.Write([]byte("yo"))
gold := `<11>2 1982-06-25T12:00:00Z fn - - - - call_id=12345 func_name=yo/dawg app_name=myapp yo`
if b1.String() != gold {
t.Fatal("syslog was not what we expected: ", b1.String())
}
}