github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/netconf/flags_test.go (about)

     1  package netconf_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/onflow/flow-go/network/netconf"
     7  )
     8  
     9  // TestBuildFlagName tests the BuildFlagName function for various cases
    10  func TestBuildFlagName(t *testing.T) {
    11  	tests := []struct {
    12  		name     string
    13  		keys     []string
    14  		expected string
    15  	}{
    16  		{
    17  			name:     "Single key",
    18  			keys:     []string{"key1"},
    19  			expected: "key1",
    20  		},
    21  		{
    22  			name:     "Two keys",
    23  			keys:     []string{"key1", "key2"},
    24  			expected: "key1-key2",
    25  		},
    26  		{
    27  			name:     "Multiple keys",
    28  			keys:     []string{"key1", "key2", "key3"},
    29  			expected: "key1-key2-key3",
    30  		},
    31  		{
    32  			name:     "No keys",
    33  			keys:     []string{},
    34  			expected: "",
    35  		},
    36  		{
    37  			name:     "Key with spaces",
    38  			keys:     []string{"key 1", "key 2"},
    39  			expected: "key 1-key 2",
    40  		},
    41  	}
    42  
    43  	for _, tt := range tests {
    44  		t.Run(tt.name, func(t *testing.T) {
    45  			result := netconf.BuildFlagName(tt.keys...)
    46  			if result != tt.expected {
    47  				t.Errorf("BuildFlagName(%v) = %v, want %v", tt.keys, result, tt.expected)
    48  			}
    49  		})
    50  	}
    51  }