Skip to content

Commit a8b3fe2

Browse files
authored
Skip some pgMonitor tests when not configured
My editor can run individual Go tests, but I don't have it configured with every variable in the Makefile. With this, `go test ./...` passes in a minimal environment.
1 parent 807633b commit a8b3fe2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

internal/controller/postgrescluster/pgmonitor_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ name: exporter-config
346346
// reacts when the kubernetes resources are in different states (e.g., checks
347347
// what happens when the database pod is terminating)
348348
func TestReconcilePGMonitorExporterSetupErrors(t *testing.T) {
349+
if os.Getenv("QUERIES_CONFIG_DIR") == "" {
350+
t.Skip("QUERIES_CONFIG_DIR must be set")
351+
}
352+
349353
for _, test := range []struct {
350354
name string
351355
podExecCalled bool
@@ -570,6 +574,10 @@ func TestReconcilePGMonitorExporter(t *testing.T) {
570574
// when it should be. Because the status updated when we update the setup sql from
571575
// pgmonitor (by using podExec), we check if podExec is called when a change is needed.
572576
func TestReconcilePGMonitorExporterStatus(t *testing.T) {
577+
if os.Getenv("QUERIES_CONFIG_DIR") == "" {
578+
t.Skip("QUERIES_CONFIG_DIR must be set")
579+
}
580+
573581
for _, test := range []struct {
574582
name string
575583
exporterEnabled bool

internal/pgmonitor/exporter_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package pgmonitor
1717

1818
import (
1919
"context"
20+
"os"
2021
"strings"
2122
"testing"
2223

@@ -28,6 +29,10 @@ import (
2829
)
2930

3031
func TestGenerateDefaultExporterQueries(t *testing.T) {
32+
if os.Getenv("QUERIES_CONFIG_DIR") == "" {
33+
t.Skip("QUERIES_CONFIG_DIR must be set")
34+
}
35+
3136
ctx := context.Background()
3237
cluster := &v1beta1.PostgresCluster{}
3338

0 commit comments

Comments
 (0)