github.com/jfrog/frogbot/v2@v2.21.0/utils/scandetails_test.go (about) 1 package utils 2 3 import ( 4 "github.com/stretchr/testify/assert" 5 "path/filepath" 6 "testing" 7 ) 8 9 func TestCreateXrayScanParams(t *testing.T) { 10 // Project 11 scanDetails := &ScanDetails{} 12 scanDetails.SetXrayGraphScanParams(nil, "", false) 13 assert.Empty(t, scanDetails.Watches) 14 assert.Equal(t, "", scanDetails.ProjectKey) 15 assert.True(t, scanDetails.IncludeVulnerabilities) 16 assert.False(t, scanDetails.IncludeLicenses) 17 18 // Watches 19 scanDetails.SetXrayGraphScanParams([]string{"watch-1", "watch-2"}, "", false) 20 assert.Equal(t, []string{"watch-1", "watch-2"}, scanDetails.Watches) 21 assert.Equal(t, "", scanDetails.ProjectKey) 22 assert.False(t, scanDetails.IncludeVulnerabilities) 23 assert.False(t, scanDetails.IncludeLicenses) 24 25 // Project 26 scanDetails.SetXrayGraphScanParams(nil, "project", true) 27 assert.Empty(t, scanDetails.Watches) 28 assert.Equal(t, "project", scanDetails.ProjectKey) 29 assert.False(t, scanDetails.IncludeVulnerabilities) 30 assert.True(t, scanDetails.IncludeLicenses) 31 } 32 33 func TestGetFullPathWorkingDirs(t *testing.T) { 34 sampleProject := Project{ 35 WorkingDirs: []string{filepath.Join("a", "b"), filepath.Join("a", "b", "c"), ".", filepath.Join("c", "d", "e", "f")}, 36 } 37 baseWd := "tempDir" 38 fullPathWds := GetFullPathWorkingDirs(sampleProject.WorkingDirs, baseWd) 39 expectedWds := []string{filepath.Join("tempDir", "a", "b"), filepath.Join("tempDir", "a", "b", "c"), "tempDir", filepath.Join("tempDir", "c", "d", "e", "f")} 40 for _, expectedWd := range expectedWds { 41 assert.Contains(t, fullPathWds, expectedWd) 42 } 43 }