forked from Devils-Knight/Testing
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdependabot.go
42 lines (39 loc) · 1.11 KB
/
dependabot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"github.com/step-security/secure-workflows/remediation/dependabot"
)
func TestingDependabot() {
test := struct {
fileName string
Ecosystems []dependabot.Ecosystem
isChanged bool
}{
fileName: "Same-ecosystem-different-directory.yml",
Ecosystems: []dependabot.Ecosystem{{PackageEcosystem: "github-actions", Directory: "/", Interval: "daily"}, {PackageEcosystem: "npm", Directory: "/sample", Interval: "daily"}},
isChanged: true,
}
// add more test using loop
var updateDependabotConfigRequest dependabot.UpdateDependabotConfigRequest
input, err := ioutil.ReadFile("./testfiles/dependabot/test1.yml")
if err != nil {
fmt.Printf("not reading file")
return
}
updateDependabotConfigRequest.Content = string(input)
updateDependabotConfigRequest.Ecosystems = test.Ecosystems
inputRequest, err := json.Marshal(updateDependabotConfigRequest)
if err != nil {
log.Fatal(err)
return
}
output, err := dependabot.UpdateDependabotConfig(string(inputRequest))
if err != nil {
log.Fatal(err)
return
}
fmt.Printf(output.FinalOutput)
}