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

fix(inputs.postgresql_extensible): Restore outputaddress behavior #13972

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test for parsing output address
  • Loading branch information
powersj committed Sep 21, 2023
commit 868f75eee091e8faf7948009efe8625c4beb4e08
45 changes: 36 additions & 9 deletions plugins/inputs/postgresql_extensible/postgresql_extensible_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,21 +294,48 @@ func TestPostgresqlIgnoresUnwantedColumnsIntegration(t *testing.T) {
func TestAccRow(t *testing.T) {
p := Postgresql{
Log: testutil.Logger{},
Service: postgresql.Service{
OutputAddress: "server",
},
}

var acc testutil.Accumulator
columns := []string{"datname", "cat"}

testRows := []fakeRow{
{fields: []interface{}{1, "gato"}},
{fields: []interface{}{nil, "gato"}},
{fields: []interface{}{"name", "gato"}},
tests := []struct {
fields fakeRow
dbName string
server string
}{
{
fields: fakeRow{
fields: []interface{}{1, "gato"},
},
dbName: "server",
server: "server",
},
{
fields: fakeRow{
fields: []interface{}{nil, "gato"},
},
dbName: "server",
server: "server",
},
{
fields: fakeRow{
fields: []interface{}{"name", "gato"},
},
dbName: "name",
server: "server",
},
}
for i := range testRows {
err := p.accRow("pgTEST", testRows[i], &acc, columns)
if err != nil {
t.Fatalf("Scan failed: %s", err)
}
for _, tt := range tests {
require.NoError(t, p.accRow("pgTEST", tt.fields, &acc, columns))
require.Equal(t, 1, len(acc.Metrics))
metric := acc.Metrics[0]
require.Equal(t, tt.dbName, metric.Tags["db"])
require.Equal(t, tt.server, metric.Tags["server"])
acc.ClearMetrics()
}
}

Expand Down