github.com/newrelic/newrelic-client-go@v1.1.0/pkg/apm/applications_metrics_test.go (about)

     1  package apm
     2  
     3  import (
     4  	"encoding/json"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestUnmarshalTimesliceValues(t *testing.T) {
    11  	data := []byte(`{
    12  		"as_percentage": 10.3,
    13  		"average_time": 133.1,
    14  		"calls_per_minute": 3029.409,
    15  		"max_value": 500,
    16  		"total_call_time_per_minute": 123.122,
    17  		"standard_deviation": 100.155,
    18  		"other_key": 22.11
    19  	}`)
    20  
    21  	expect := &MetricTimesliceValues{
    22  		AsPercentage:           10.3,
    23  		AverageTime:            133.1,
    24  		CallsPerMinute:         3029.409,
    25  		MaxValue:               500.0,
    26  		TotalCallTimePerMinute: 123.122,
    27  		Utilization:            0.0,
    28  		Values: map[string]float64{
    29  			"as_percentage":              10.3,
    30  			"average_time":               133.1,
    31  			"calls_per_minute":           3029.409,
    32  			"max_value":                  500.0,
    33  			"total_call_time_per_minute": 123.122,
    34  			"standard_deviation":         100.155,
    35  			"other_key":                  22.11,
    36  		},
    37  	}
    38  
    39  	values := MetricTimesliceValues{}
    40  
    41  	require.NoError(t, json.Unmarshal(data, &values))
    42  
    43  	require.Equal(t, expect, &values)
    44  }