Skip to content

Commit

Permalink
adding more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Paramadon committed Sep 30, 2024
1 parent e4308f8 commit 14039cf
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions plugins/inputs/procstat/procstat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,24 @@ func TestGather_MemorySwap(t *testing.T) {
fields := acc.Metrics[0].Fields
require.Equal(t, int64(1024), fields["memory_swap"])
}

func TestGather_NoMemorySwap(t *testing.T) {
var acc testutil.Accumulator

p := Procstat{
Exe: exe,
createPIDFinder: pidFinder([]PID{pid}),
createProcess: func(PID) (Process, error) {
proc := &testProc{
pid: pid,
tags: map[string]string{
"exe": exe,
},
}
return proc, nil
},
}

require.NoError(t, acc.GatherError(p.Gather))
require.False(t, acc.HasField("procstat", "memory_swap"))
}

0 comments on commit 14039cf

Please sign in to comment.