Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemlogs and iptables unit-tests. #123

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions pkg/collector/iptables_collector_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package collector

import (
"testing"
)

func TestNewIPTablesCollector(t *testing.T) {
tests := []struct {
name string
want int
wantErr bool
collectorName string
}{
{
name: "get iptables logs",
want: 1,
wantErr: false,
collectorName: "iptables",
},
}

c := NewIPTablesCollector()

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := c.Collect()
if (err != nil) != tt.wantErr {
t.Errorf("Collect() error = %v, wantErr %v", err, tt.wantErr)
}

// Get Data test needs to be written as the current test dont run at node level.

name := c.GetName()
if name != tt.collectorName {
t.Errorf("GetName()) = %v, want %v", name, tt.collectorName)
}
})
}
}
39 changes: 39 additions & 0 deletions pkg/collector/systemlogs_collector_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package collector

import (
"testing"
)

func TestNewSystemLogsCollector(t *testing.T) {
tests := []struct {
name string
want int
wantErr bool
collectorName string
}{
{
name: "get system logs",
want: 1,
wantErr: false,
collectorName: "systemlogs",
},
}

c := NewSystemLogsCollector()

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := c.Collect()
if (err != nil) != tt.wantErr {
t.Errorf("Collect() error = %v, wantErr %v", err, tt.wantErr)
}

// Get Data test needs to be written as the current test dont run at node level.

name := c.GetName()
if name != tt.collectorName {
t.Errorf("GetName()) = %v, want %v", name, tt.collectorName)
}
})
}
}