Skip to content

Commit

Permalink
resolved : lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tharun0064 committed Jan 15, 2025
1 parent 3e4368b commit befb1ed
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/newrelic/nri-postgresql/src/collection"
"github.com/newrelic/nri-postgresql/src/query-performance-monitoring/common-utils"
commonutils "github.com/newrelic/nri-postgresql/src/query-performance-monitoring/common-utils"
"github.com/stretchr/testify/assert"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/newrelic/infra-integrations-sdk/v3/integration"
"github.com/newrelic/nri-postgresql/src/args"
"github.com/newrelic/nri-postgresql/src/query-performance-monitoring/common-utils"
commonutils "github.com/newrelic/nri-postgresql/src/query-performance-monitoring/common-utils"
"github.com/stretchr/testify/assert"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package commonutils_test

import (
commonutils "github.com/newrelic/nri-postgresql/src/query-performance-monitoring/common-utils"
"testing"

commonutils "github.com/newrelic/nri-postgresql/src/query-performance-monitoring/common-utils"

"github.com/newrelic/nri-postgresql/src/query-performance-monitoring/queries"
"github.com/stretchr/testify/assert"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package performancemetrics

import (
"fmt"

"github.com/newrelic/infra-integrations-sdk/v3/integration"
commonutils "github.com/newrelic/nri-postgresql/src/query-performance-monitoring/common-utils"
"github.com/newrelic/nri-postgresql/src/query-performance-monitoring/validations"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ func TestPopulateBlockingMetricsExtensionsNotEnabled(t *testing.T) {
}

func TestGetBlockingMetrics(t *testing.T) {

conn, mock := connection.CreateMockSQL(t)
args := args.ArgumentList{QueryCountThreshold: 10}
databaseName := "testdb"
version := uint64(13)

expectedQuery := queries.BlockingQueriesForV12AndV13
query := fmt.Sprintf(expectedQuery, databaseName, min(args.QueryCountThreshold, commonutils.MaxQueryThreshold))
mock.ExpectQuery(regexp.QuoteMeta(query)).WillReturnRows(sqlmock.NewRows([]string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ import (
)

func TestPopulateSlowMetrics(t *testing.T) {

conn, mock := connection.CreateMockSQL(t)
pgIntegration, _ := integration.New("test", "1.0.0")
args := args.ArgumentList{QueryCountThreshold: 10}
databaseName := "testdb"
version := uint64(13)
validationQuery := fmt.Sprintf("SELECT count(*) FROM pg_extension WHERE extname = '%s'", "pg_stat_statements")
mock.ExpectQuery(regexp.QuoteMeta(validationQuery)).WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(1))

expectedQuery := queries.SlowQueriesForV13AndAbove
query := fmt.Sprintf(expectedQuery, "testdb", min(args.QueryCountThreshold, commonutils.MaxQueryThreshold))
mock.ExpectQuery(regexp.QuoteMeta(query)).WillReturnRows(sqlmock.NewRows([]string{
Expand All @@ -41,15 +39,13 @@ func TestPopulateSlowMetrics(t *testing.T) {
}

func TestPopulateSlowMetricsInEligibility(t *testing.T) {

conn, mock := connection.CreateMockSQL(t)
pgIntegration, _ := integration.New("test", "1.0.0")
args := args.ArgumentList{QueryCountThreshold: 10}
databaseName := "testdb"
version := uint64(13)
validationQuery := fmt.Sprintf("SELECT count(*) FROM pg_extension WHERE extname = '%s'", "pg_stat_statements")
mock.ExpectQuery(regexp.QuoteMeta(validationQuery)).WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(0))

slowqueryList := performancemetrics.PopulateSlowRunningMetrics(conn, pgIntegration, args, databaseName, version)

assert.Len(t, slowqueryList, 0)
Expand Down

0 comments on commit befb1ed

Please sign in to comment.