Skip to content

Commit

Permalink
directory path test case added
Browse files Browse the repository at this point in the history
  • Loading branch information
Devils-Knight committed Jul 26, 2023
1 parent f1c6979 commit cb9e08f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion remediation/dependabot/dependabotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func UpdateDependabotConfig(dependabotConfig string) (*UpdateDependabotConfigRes
for _, Update := range updateDependabotConfigRequest.Ecosystems {
updateAlreadyExist := false
for _, update := range configMetadata.Updates {
if update.PackageEcosystem == Update.PackageEcosystem && update.Directory == Update.Directory {
if update.PackageEcosystem == Update.PackageEcosystem && (update.Directory == Update.Directory || update.Directory == Update.Directory+"/") {
updateAlreadyExist = true
break
}
Expand Down
5 changes: 5 additions & 0 deletions remediation/dependabot/dependabotconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func TestConfigDependabotFile(t *testing.T) {
Ecosystems: []Ecosystem{{"npm", "/sample", "daily"}},
isChanged: true,
},
{
fileName: "extra-slash.yml",
Ecosystems: []Ecosystem{{"npm", "/sample", "daily"}},
isChanged: false,
},
}

for _, test := range tests {
Expand Down
7 changes: 7 additions & 0 deletions testfiles/dependabotfiles/input/extra-slash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "npm"
# Files stored in `app` directory
directory: "/sample/"
schedule:
interval: "daily"
7 changes: 7 additions & 0 deletions testfiles/dependabotfiles/output/extra-slash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "npm"
# Files stored in `app` directory
directory: "/sample/"
schedule:
interval: "daily"

0 comments on commit cb9e08f

Please sign in to comment.