github.com/fastly/go-fastly/v6@v6.8.0/fastly/origin_inspector_test.go (about)

     1  package fastly
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  )
     7  
     8  func TestClient_GetOriginMetricsForService(t *testing.T) {
     9  	t.Parallel()
    10  
    11  	// NOTE: Update this to a recent time when regenerating the test fixtures,
    12  	// otherwise the data may be outside of retention and an error will be
    13  	// returned.
    14  	end := time.Date(2022, 2, 14, 0, 0, 0, 0, time.UTC)
    15  	start := end.Add(-2 * 24 * time.Hour)
    16  	var err error
    17  	record(t, "origin_inspector/metrics_for_service", func(c *Client) {
    18  		_, err = c.GetOriginMetricsForService(&GetOriginMetricsInput{
    19  			ServiceID:   testServiceID,
    20  			Start:       start,
    21  			End:         end,
    22  			Hosts:       []string{"host01"},
    23  			Datacenters: []string{"LHR", "JFK"},
    24  			Metrics:     []string{"responses", "status_2xx"},
    25  			GroupBy:     []string{"host"},
    26  			Downsample:  "day",
    27  			Regions:     []string{"europe", "usa"},
    28  			Cursor:      "",
    29  		})
    30  	})
    31  	if err != nil {
    32  		t.Fatal(err)
    33  	}
    34  }