Skip to content

Commit

Permalink
newrelic changes
Browse files Browse the repository at this point in the history
Signed-off-by: kshamajain99 <[email protected]>
  • Loading branch information
kshamajain99 committed Feb 1, 2022
1 parent 55eb27b commit ce9ed09
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions metricproviders/newrelic/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package newrelic
import "github.com/newrelic/newrelic-client-go/pkg/nrdb"

type mockAPI struct {
response []nrdb.NrdbResult
response []nrdb.NRDBResult
err error
}

func (m *mockAPI) Query(query string) ([]nrdb.NrdbResult, error) {
func (m *mockAPI) Query(query string) ([]nrdb.NRDBResult, error) {
if m.err != nil {
return nil, m.err
}
Expand Down
8 changes: 4 additions & 4 deletions metricproviders/newrelic/newrelic.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
var userAgent = fmt.Sprintf("argo-rollouts/%s (%s)", version.GetVersion(), repoURL)

type NewRelicClientAPI interface {
Query(query string) ([]nrdb.NrdbResult, error)
Query(query string) ([]nrdb.NRDBResult, error)
}

type NewRelicClient struct {
Expand All @@ -40,8 +40,8 @@ type NewRelicClient struct {
}

//Query executes a NRQL query against the given New Relic account
func (n *NewRelicClient) Query(query string) ([]nrdb.NrdbResult, error) {
results, err := n.Nrdb.Query(n.AccountID, nrdb.Nrql(query))
func (n *NewRelicClient) Query(query string) ([]nrdb.NRDBResult, error) {
results, err := n.Nrdb.Query(n.AccountID, nrdb.NRQL(query))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -86,7 +86,7 @@ func toJSONString(v interface{}) (string, error) {
return string(b), nil
}

func (p *Provider) processResponse(metric v1alpha1.Metric, results []nrdb.NrdbResult) (string, v1alpha1.AnalysisPhase, error) {
func (p *Provider) processResponse(metric v1alpha1.Metric, results []nrdb.NRDBResult) (string, v1alpha1.AnalysisPhase, error) {
if len(results) == 1 {
result := results[0]
if len(result) == 0 {
Expand Down
14 changes: 7 additions & 7 deletions metricproviders/newrelic/newrelic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestType(t *testing.T) {
func TestRunSuccessfully(t *testing.T) {
e := log.Entry{}
mock := &mockAPI{
response: []nrdb.NrdbResult{map[string]interface{}{"count": 10}},
response: []nrdb.NRDBResult{map[string]interface{}{"count": 10}},
}
p := NewNewRelicProvider(mock, e)
metric := v1alpha1.Metric{
Expand All @@ -54,7 +54,7 @@ func TestRunSuccessfully(t *testing.T) {
func TestRunWithTimeseries(t *testing.T) {
e := log.NewEntry(log.New())
mock := &mockAPI{
response: []nrdb.NrdbResult{
response: []nrdb.NRDBResult{
map[string]interface{}{"count": 10},
map[string]interface{}{"count": 20},
map[string]interface{}{"count": 30}},
Expand All @@ -80,7 +80,7 @@ func TestRunWithTimeseries(t *testing.T) {
func TestRunWithFacet(t *testing.T) {
e := log.NewEntry(log.New())
mock := &mockAPI{
response: []nrdb.NrdbResult{map[string]interface{}{"count": 10, "average.duration": 12.34}},
response: []nrdb.NRDBResult{map[string]interface{}{"count": 10, "average.duration": 12.34}},
}
p := NewNewRelicProvider(mock, *e)
metric := v1alpha1.Metric{
Expand All @@ -103,7 +103,7 @@ func TestRunWithFacet(t *testing.T) {
func TestRunWithMultipleSelectTerms(t *testing.T) {
e := log.NewEntry(log.New())
mock := &mockAPI{
response: []nrdb.NrdbResult{map[string]interface{}{"count": 10}},
response: []nrdb.NRDBResult{map[string]interface{}{"count": 10}},
}
p := NewNewRelicProvider(mock, *e)
metric := v1alpha1.Metric{
Expand All @@ -127,7 +127,7 @@ func TestRunWithEmptyResult(t *testing.T) {
e := log.NewEntry(log.New())
expectedErr := fmt.Errorf("no results returned from NRQL query")
mock := &mockAPI{
response: []nrdb.NrdbResult{make(map[string]interface{})},
response: []nrdb.NRDBResult{make(map[string]interface{})},
}
p := NewNewRelicProvider(mock, *e)
metric := v1alpha1.Metric{
Expand Down Expand Up @@ -233,7 +233,7 @@ func TestRunWithInvalidJSON(t *testing.T) {
}
t.Run("with a single result map", func(t *testing.T) {
mock := &mockAPI{
response: []nrdb.NrdbResult{map[string]interface{}{"func": func() {}}},
response: []nrdb.NRDBResult{map[string]interface{}{"func": func() {}}},
}
p := NewNewRelicProvider(mock, *e)
measurement := p.Run(newAnalysisRun(), metric)
Expand All @@ -246,7 +246,7 @@ func TestRunWithInvalidJSON(t *testing.T) {
t.Run("with multiple results", func(t *testing.T) {
// cover branch where results slice is longer than 1
mock := &mockAPI{
response: []nrdb.NrdbResult{map[string]interface{}{"key": "value"}, map[string]interface{}{"func": func() {}}},
response: []nrdb.NRDBResult{map[string]interface{}{"key": "value"}, map[string]interface{}{"func": func() {}}},
}
p := NewNewRelicProvider(mock, *e)
measurement := p.Run(newAnalysisRun(), metric)
Expand Down

0 comments on commit ce9ed09

Please sign in to comment.