github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/gosbom/formats/common/spdxhelpers/spdxid_test.go (about)

     1  package spdxhelpers
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func Test_SanitizeElementID(t *testing.T) {
    10  	tests := []struct {
    11  		input    string
    12  		expected string
    13  	}{
    14  		{
    15  			input:    "letters",
    16  			expected: "letters",
    17  		},
    18  		{
    19  			input:    "ssl-client",
    20  			expected: "ssl-client",
    21  		},
    22  		{
    23  			input:    "ssl_client",
    24  			expected: "ssl-client",
    25  		},
    26  		{
    27  			input:    "go-module-sigs.k8s.io/structured-merge-diff/v3",
    28  			expected: "go-module-sigs.k8s.io-structured-merge-diff-v3",
    29  		},
    30  	}
    31  
    32  	for _, test := range tests {
    33  		t.Run(test.input, func(t *testing.T) {
    34  			actual := SanitizeElementID(test.input)
    35  
    36  			assert.Equal(t, test.expected, actual)
    37  		})
    38  	}
    39  }