github.com/lineaje-labs/syft@v0.98.1-0.20231227153149-9e393f60ff1b/syft/pkg/cataloger/ruby/package_test.go (about)

     1  package ruby
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/google/go-cmp/cmp"
     8  )
     9  
    10  func Test_packageURL(t *testing.T) {
    11  	tests := []struct {
    12  		name     string
    13  		version  string
    14  		expected string
    15  	}{
    16  		{
    17  			name:     "p",
    18  			version:  "v",
    19  			expected: "pkg:gem/p@v",
    20  		},
    21  	}
    22  
    23  	for _, test := range tests {
    24  		t.Run(fmt.Sprintf("%s@%s", test.name, test.version), func(t *testing.T) {
    25  			actual := packageURL(test.name, test.version)
    26  			if diff := cmp.Diff(test.expected, actual); diff != "" {
    27  				t.Errorf("unexpected packageURL (-want +got):\n%s", diff)
    28  			}
    29  		})
    30  	}
    31  }