Skip to content

Commit

Permalink
Added tests for custom events configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mirackara committed Jun 27, 2022
1 parent 0385173 commit 0f2998d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app_run.go
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/json"
"strings"
"time"

"github.com/newrelic/go-agent/internal"
)

Expand Down Expand Up @@ -181,6 +180,8 @@ func (run *appRun) MaxErrorEvents() int {
return run.limit(internal.MaxErrorEvents, run.ptrErrorEvents)
}
func (run *appRun) MaxSpanEvents() int { return run.limit(internal.MaxSpanEvents, run.ptrSpanEvents) }
func (run *appRun) MaxSamplesStored() int { return run.limit(internal.MaxSamplesStored, run.ptrCustomEvents) }


func (run *appRun) limit(dflt int, field func() *uint) int {
if nil != field() {
Expand Down
21 changes: 21 additions & 0 deletions v3/newrelic/app_run_test.go
Expand Up @@ -324,6 +324,27 @@ func TestConfigurableTxnEvents_withCollResponse(t *testing.T) {
}
}

func TestConfigurableMaxCustomEventsDefault(t *testing.T) {
reply := internal.ConnectReplyDefaults()
expected := 10000
cfg := config{Config: defaultConfig()}
result := newAppRun(cfg, reply).MaxCustomEvents()
if result != expected {
t.Errorf("Unexpected max number of custom events, expected %d but got %d", expected, result)
}
}

func TestConfigurableMaxCustomEvents(t *testing.T) {
reply := internal.ConnectReplyDefaults()
expected := 1000
cfg := config{Config: defaultConfig()}
cfg.CustomInsightsEvents.MaxSamplesStored = expected
result := newAppRun(cfg, reply).MaxCustomEvents()
if result != expected {
t.Errorf("Unexpected max number of custom events, expected %d but got %d", expected, result)
}
}

func TestConfigurableTxnEvents_notInCollResponse(t *testing.T) {
reply, err := internal.UnmarshalConnectReply([]byte(
`{"return_value":{
Expand Down

0 comments on commit 0f2998d

Please sign in to comment.