github.com/MetalBlockchain/metalgo@v1.11.9/utils/metric/namespace_test.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package metric
     5  
     6  import (
     7  	"strings"
     8  	"testing"
     9  
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  func TestAppendNamespace(t *testing.T) {
    14  	tests := []struct {
    15  		prefix   string
    16  		suffix   string
    17  		expected string
    18  	}{
    19  		{
    20  			prefix:   "avalanchego",
    21  			suffix:   "isgreat",
    22  			expected: "avalanchego_isgreat",
    23  		},
    24  		{
    25  			prefix:   "",
    26  			suffix:   "sucks",
    27  			expected: "sucks",
    28  		},
    29  		{
    30  			prefix:   "sucks",
    31  			suffix:   "",
    32  			expected: "sucks",
    33  		},
    34  		{
    35  			prefix:   "",
    36  			suffix:   "",
    37  			expected: "",
    38  		},
    39  	}
    40  	for _, test := range tests {
    41  		t.Run(strings.Join([]string{test.prefix, test.suffix}, "_"), func(t *testing.T) {
    42  			namespace := AppendNamespace(test.prefix, test.suffix)
    43  			require.Equal(t, test.expected, namespace)
    44  		})
    45  	}
    46  }