MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / TestFormat

Function TestFormat

pkg/event/formatter_test.go:53–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func TestFormat(t *testing.T) {
54 template := "{{ .Seq }} {{.CPU}} - ({{.Type}}) -- pid: {{ .Params.Pid }} ({{.Params}}) {{ .Meta }}"
55 f, err := NewFormatter(template)
56 require.NoError(t, err)
57 params := Params{
58 kpars.ProcessID: {Name: kpars.ProcessID, Type: kpars.PID, Value: uint32(876)},
59 }
60 s := f.Format(&Event{CPU: uint8(4), Name: "CreateProcess", Seq: uint64(1999), Params: params, Metadata: map[MetadataKey]any{"key1": "value1"}})
61 assert.Equal(t, "1999 4 - (CreateProcess) -- pid: 876 (pid➜ 876) key1: value1", string(s))
62}
63
64func TestFormatPS(t *testing.T) {
65 template := "{{ .Seq }} {{ .Process }} ({{ .Cwd }}) {{ .Ppid }} ({{ .Sid }})"

Callers

nothing calls this directly

Calls 3

FormatMethod · 0.95
NewFormatterFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected