feat: Add JSON logging
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
18cbc70495
commit
e72feaf0f6
8 changed files with 77 additions and 13 deletions
|
|
@ -1,9 +1,32 @@
|
|||
package base
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSessionJSON(t *testing.T) {
|
||||
session := &Session{
|
||||
Pid: 1,
|
||||
User: "test",
|
||||
Db: "db",
|
||||
Client: "127.0.0.1:5432",
|
||||
State: "active",
|
||||
Query: "select 1",
|
||||
StateDuration: 1.5,
|
||||
ApplicationName: "psql",
|
||||
}
|
||||
|
||||
var got Session
|
||||
if err := json.Unmarshal([]byte(session.JSON()), &got); err != nil {
|
||||
t.Fatalf("invalid JSON: %v", err)
|
||||
}
|
||||
|
||||
if got != *session {
|
||||
t.Errorf("got %+v; want %+v", got, *session)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionEqual(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue