github.com/moov-io/imagecashletter@v0.10.1/internal/metrics/http_test.go (about)

     1  // Copyright 2020 The Moov Authors
     2  // Use of this source code is governed by an Apache License
     3  // license that can be found in the LICENSE file.
     4  
     5  package metrics
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  func TestHTTP_cleanMetricsPath(t *testing.T) {
    14  	require.Equal(t, "v1-customers-companies", cleanMetricsPath("/v1/customers/companies/1234"))
    15  	require.Equal(t, "v1-customers-ping", cleanMetricsPath("/v1/customers/ping"))
    16  	require.Equal(t, "v1-customers-customers", cleanMetricsPath("/v1/customers/customers/19636f90bc95779e2488b0f7a45c4b68958a2ddd"))
    17  
    18  	// A value which looks like moov/base.ID, but is off by one character (last letter)
    19  	require.Equal(t, "v1-customers-customers-19636f90bc95779e2488b0f7a45c4b68958a2ddz", cleanMetricsPath("/v1/customers/customers/19636f90bc95779e2488b0f7a45c4b68958a2ddz"))
    20  }