1- package integrations_test
1+ package integrations
22
33import (
44 "fmt"
55 "testing"
66
77 "github.com/google/uuid"
8- "github.com/l3montree-dev/devguard/internal/core/integrations"
98 "github.com/l3montree-dev/devguard/internal/database/models"
109 "github.com/l3montree-dev/devguard/internal/utils"
1110 "github.com/l3montree-dev/devguard/mocks"
@@ -14,7 +13,7 @@ import (
1413)
1514
1615func TestRenderPathToComponent (t * testing.T ) {
17- t .Run ("Everythings works as expected with empty lists" , func (t * testing.T ) {
16+ t .Run ("Everything works as expected with empty lists" , func (t * testing.T ) {
1817
1918 components := []models.ComponentDependency {}
2019 componentRepository := mocks .NewCoreComponentRepository (t )
@@ -25,7 +24,7 @@ func TestRenderPathToComponent(t *testing.T) {
2524 scannerID := "SBOM-File-Upload"
2625 pURL := "pkg:npm:test"
2726
28- result , err := integrations . RenderPathToComponent (componentRepository , assetID , assetVersionName , scannerID , pURL )
27+ result , err := renderPathToComponent (componentRepository , assetID , assetVersionName , scannerID , pURL )
2928 if err != nil {
3029 t .Fail ()
3130 }
@@ -42,15 +41,15 @@ func TestRenderPathToComponent(t *testing.T) {
4241 scannerID := "SBOM-File-Upload"
4342 pURL := "pkg:npm:test"
4443
45- _ , err := integrations . RenderPathToComponent (componentRepository , assetID , assetVersionName , scannerID , pURL )
44+ _ , err := renderPathToComponent (componentRepository , assetID , assetVersionName , scannerID , pURL )
4645 if err == nil {
4746 t .Fail ()
4847 }
4948
5049 })
5150 t .Run ("Everything works as expeted with a non empty component list" , func (t * testing.T ) {
5251 components := []models.ComponentDependency {
53- {ComponentPurl : utils . Ptr ( "testPURL" ) , DependencyPurl : "testDependency" },
52+ {ComponentPurl : nil , DependencyPurl : "testDependency" }, // root --> testDependency
5453 {ComponentPurl : utils .Ptr ("testomatL" ), DependencyPurl : "testPURL" },
5554 {ComponentPurl : utils .Ptr ("testDependency" ), DependencyPurl : "testPURL" },
5655 }
@@ -62,37 +61,36 @@ func TestRenderPathToComponent(t *testing.T) {
6261 scannerID := "SBOM-File-Upload"
6362 pURL := "pkg:npm:test"
6463
65- result , err := integrations . RenderPathToComponent (componentRepository , assetID , assetVersionName , scannerID , pURL )
64+ result , err := renderPathToComponent (componentRepository , assetID , assetVersionName , scannerID , pURL )
6665 if err != nil {
6766 t .Fail ()
6867 }
6968
7069 //String for the empty graph + 1 node being root with a linebreak
71- assert .Equal (t , "```mermaid \n %%{init: { 'theme':'dark' } }%%\n flowchart TD\n root\n ```\n " , result )
70+ assert .Equal (t , "```mermaid \n %%{init: { 'theme':'dark' } }%%\n flowchart TD\n root --> \n node0[testDependency] --> \n node1[testPURL] \n ```\n " , result )
7271
7372 })
7473}
7574
7675func TestBeautifyPURL (t * testing.T ) {
7776 t .Run ("empty String should also return an empty string back" , func (t * testing.T ) {
7877 inputString := ""
79- result , _ := integrations . BeautifyPURL (inputString )
78+ result , _ := beautifyPURL (inputString )
8079 assert .Equal (t , "" , result )
8180 })
8281 t .Run ("invalid purl format should also be returned unchanged" , func (t * testing.T ) {
8382 inputString := "this is definitely not a valid purl"
84- result , _ := integrations . BeautifyPURL (inputString )
83+ result , _ := beautifyPURL (inputString )
8584 assert .Equal (t , inputString , result )
8685 })
8786 t .Run ("should return only the namespace and the name of a valid purl and cut the rest" , func (t * testing.T ) {
8887 inputString := "pkg:npm/@ory/integrations@v0.0.1"
89- result , _ := integrations . BeautifyPURL (inputString )
88+ result , _ := beautifyPURL (inputString )
9089 assert .Equal (t , "@ory/integrations" , result )
9190 })
9291 t .Run ("should return no leading slash if the namespace is empty" , func (t * testing.T ) {
9392 inputString := "pkg:npm/integrations@v0.0.1"
94- result , _ := integrations . BeautifyPURL (inputString )
93+ result , _ := beautifyPURL (inputString )
9594 assert .Equal (t , "integrations" , result )
9695 })
97-
9896}
0 commit comments