Skip to content

Commit

Permalink
CR and testsFixes
Browse files Browse the repository at this point in the history
  • Loading branch information
asafambar committed Feb 28, 2024
1 parent 1bec57a commit 36476a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
27 changes: 17 additions & 10 deletions commands/curation/curationaudit.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,16 @@ var supportedTech = map[coreutils.Technology]func(ca *CurationAuditCommand) (boo
}

func (ca *CurationAuditCommand) checkSupportByVersionOrEnv(tech coreutils.Technology, minRtVersion, minXrayVersion, envName string) (bool, error) {
flag, errResolveFlag := clientutils.GetBoolEnvValue(envName, false)
if errResolveFlag != nil {
log.Error(errResolveFlag)
}
if flag {
if flag, err := clientutils.GetBoolEnvValue(envName, false); flag {
return true, nil
} else if err != nil {
log.Error(err)
}
rtManager, serverDetails, err := ca.getRtManagerAndAuth(tech)
if err != nil {
return false, err
}
rtVersion, err := rtManager.GetVersion()
rtVersion, serverDetails, err := ca.getRtVersionAndServiceDetails(tech)
if err != nil {
return false, err
}

_, xrayVersion, err := utils.CreateXrayServiceManagerAndGetVersion(serverDetails)
if err != nil {
return false, err
Expand All @@ -94,6 +89,18 @@ func (ca *CurationAuditCommand) checkSupportByVersionOrEnv(tech coreutils.Techno
return true, nil
}

func (ca *CurationAuditCommand) getRtVersionAndServiceDetails(tech coreutils.Technology) (string, *config.ServerDetails, error) {
rtManager, serveDetails, err := ca.getRtManagerAndAuth(tech)
if err != nil {
return "", nil, err
}
rtVersion, err := rtManager.GetVersion()
if err != nil {
return "", nil, err
}
return rtVersion, serveDetails, err
}

type ErrorsResp struct {
Errors []ErrorResp `json:"errors"`
}
Expand Down
4 changes: 2 additions & 2 deletions commands/curation/curationaudit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func TestGetNameScopeAndVersion(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotDownloadUrl, gotName, gotScope, gotVersion := getNpmNameScopeAndVersion(tt.componentId, tt.artiUrl, tt.repo, tt.repo)
assert.Equal(t, tt.wantDownloadUrl, gotDownloadUrl, "getNameScopeAndVersion() gotDownloadUrl = %v, want %v", gotDownloadUrl, tt.wantDownloadUrl)
assert.Equal(t, tt.wantDownloadUrl, gotDownloadUrl[0], "getNameScopeAndVersion() gotDownloadUrl = %v, want %v", gotDownloadUrl[0], tt.wantDownloadUrl)
assert.Equal(t, tt.wantName, gotName, "getNpmNameScopeAndVersion() gotName = %v, want %v", gotName, tt.wantName)
assert.Equal(t, tt.wantScope, gotScope, "getNpmNameScopeAndVersion() gotScope = %v, want %v", gotScope, tt.wantScope)
assert.Equal(t, tt.wantVersion, gotVersion, "getNpmNameScopeAndVersion() gotVersion = %v, want %v", gotVersion, tt.wantVersion)
Expand Down Expand Up @@ -401,7 +401,7 @@ func fillSyncedMap(pkgStatus []*PackageStatus) *sync.Map {
return &syncMap
}

func TestDoCurationAuditNpm(t *testing.T) {
func TestDoCurationAudit(t *testing.T) {
tests := getTestCasesForDoCurationAudit()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 36476a8

Please sign in to comment.