Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbauriedel committed Aug 28, 2024
1 parent b8e7175 commit 001b3df
Show file tree
Hide file tree
Showing 20 changed files with 96 additions and 11 deletions.
6 changes: 6 additions & 0 deletions modules/ansible/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package ansible

import (
"bytes"
"github.com/NETWAYS/support-collector/internal/util"
"testing"

"github.com/NETWAYS/support-collector/internal/collection"
"github.com/stretchr/testify/assert"
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find ansible in the test environment")
return
}

buf := &bytes.Buffer{}
c := collection.New(buf)

Expand Down
6 changes: 6 additions & 0 deletions modules/corosync/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package corosync

import (
"bytes"
"github.com/NETWAYS/support-collector/internal/util"
"testing"

"github.com/NETWAYS/support-collector/internal/collection"
"github.com/stretchr/testify/assert"
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find corosync in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
5 changes: 5 additions & 0 deletions modules/elastic/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find elastic in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
6 changes: 0 additions & 6 deletions modules/foreman/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package foreman

import (
"github.com/NETWAYS/support-collector/internal/util"
"os"
"path/filepath"

"github.com/NETWAYS/support-collector/internal/collection"
Expand All @@ -27,11 +26,6 @@ var detailedFiles = []string{
"/var/log/foreman-proxy",
}

func detect() bool {
_, err := os.Stat("/etc/foreman")
return err == nil
}

var obfuscaters = []*obfuscate.Obfuscator{
obfuscate.NewFile(`(?i)(?:password)\s*:\s*(.*)`, "yml"),
obfuscate.NewFile(`(?i)(?:ENCRYPTION_KEY)\s*=\s*(.*)`, "rb"),
Expand Down
6 changes: 3 additions & 3 deletions modules/foreman/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
)

func TestCollect(t *testing.T) {
c := collection.New(&bytes.Buffer{})

if !detect() {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find foreman in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)

err := c.Close()
Expand Down
6 changes: 6 additions & 0 deletions modules/grafana/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package grafana

import (
"bytes"
"github.com/NETWAYS/support-collector/internal/util"
"testing"

"github.com/NETWAYS/support-collector/internal/collection"
"github.com/stretchr/testify/assert"
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find grafana in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
6 changes: 6 additions & 0 deletions modules/graphite/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package graphite

import (
"bytes"
"github.com/NETWAYS/support-collector/internal/util"
"testing"

"github.com/NETWAYS/support-collector/internal/collection"
"github.com/stretchr/testify/assert"
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find graphite in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
5 changes: 5 additions & 0 deletions modules/graylog/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find graylog in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
7 changes: 6 additions & 1 deletion modules/icinga2/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import (
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find icinga2 in the test environment")
return
}

file, err := os.ReadFile("testdata/icinga-version.txt")
if err != nil {
t.Skip("cant read version file")
Expand All @@ -22,7 +27,7 @@ func TestCollect(t *testing.T) {
t.Skip("cant detect icinga2 version")
}

if !detectIcinga() {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find icinga2 in the test environment")
return
}
Expand Down
6 changes: 6 additions & 0 deletions modules/icingadb/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package icingadb

import (
"bytes"
"github.com/NETWAYS/support-collector/internal/util"
"testing"

"github.com/NETWAYS/support-collector/internal/collection"
"github.com/stretchr/testify/assert"
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find icingadb in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
6 changes: 6 additions & 0 deletions modules/icingadirector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package icingadirector

import (
"bytes"
"github.com/NETWAYS/support-collector/internal/util"
"testing"

"github.com/NETWAYS/support-collector/internal/collection"
"github.com/stretchr/testify/assert"
)

func TestCollect(t *testing.T) {
if !util.ModuleExists([]string{InstallationPath}) {
t.Skip("could not find icingadirector in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
2 changes: 1 addition & 1 deletion modules/icingaweb2/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestCollect(t *testing.T) {
if !Detect() {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find icingaweb2 in the test environment")
return
}
Expand Down
6 changes: 6 additions & 0 deletions modules/influxdb/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package influxdb

import (
"bytes"
"github.com/NETWAYS/support-collector/internal/util"
"testing"

"github.com/NETWAYS/support-collector/internal/collection"
"github.com/stretchr/testify/assert"
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find influxdb in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
5 changes: 5 additions & 0 deletions modules/keepalived/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find keepalived in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
5 changes: 5 additions & 0 deletions modules/mongodb/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find mongodb in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
1 change: 1 addition & 0 deletions modules/mysql/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

func TestCollect(t *testing.T) {

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
6 changes: 6 additions & 0 deletions modules/postgresql/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package postgresql

import (
"bytes"
"github.com/NETWAYS/support-collector/internal/util"
"testing"

"github.com/NETWAYS/support-collector/internal/collection"
"github.com/stretchr/testify/assert"
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find postgresql in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
5 changes: 5 additions & 0 deletions modules/prometheus/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find prometheus in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
6 changes: 6 additions & 0 deletions modules/puppet/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package puppet

import (
"bytes"
"github.com/NETWAYS/support-collector/internal/util"
"testing"

"github.com/NETWAYS/support-collector/internal/collection"
"github.com/stretchr/testify/assert"
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find puppet in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down
6 changes: 6 additions & 0 deletions modules/webservers/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package webservers

import (
"bytes"
"github.com/NETWAYS/support-collector/internal/util"
"testing"

"github.com/NETWAYS/support-collector/internal/collection"
"github.com/stretchr/testify/assert"
)

func TestCollect(t *testing.T) {
if !util.ModuleExists(relevantPaths) {
t.Skip("could not find webservers in the test environment")
return
}

c := collection.New(&bytes.Buffer{})

Collect(c)
Expand Down

0 comments on commit 001b3df

Please sign in to comment.