-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathdependabot_test.go
More file actions
47 lines (42 loc) · 1.08 KB
/
dependabot_test.go
File metadata and controls
47 lines (42 loc) · 1.08 KB
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
43
44
45
46
47
package main
import (
"context"
"os"
"os/exec"
"path/filepath"
"rsc.io/script"
"rsc.io/script/scripttest"
"testing"
"time"
)
func TestDependabot(t *testing.T) {
ctx := context.Background()
err := exec.CommandContext(ctx, "go", "build", ".").Run()
if err != nil {
t.Fatal("failed to build dependabot")
}
t.Cleanup(func() {
os.Remove("dependabot")
})
engine := &script.Engine{
Conds: scripttest.DefaultConds(),
Cmds: Commands(),
Quiet: false,
}
env := []string{
"PATH=" + os.Getenv("PATH"),
}
scripttest.Test(t, ctx, engine, env, "../../testdata/scripts/*.txt")
}
// Commands returns the commands that can be used in the scripts.
// Each line of the scripts are <command> <args...>
// When you use "echo" in the scripts it's actually running script.Echo
// not the echo binary on your system.
func Commands() map[string]script.Cmd {
commands := scripttest.DefaultCmds()
wd, _ := os.Getwd()
dependabot := filepath.Join(wd, "dependabot")
// additional Dependabot commands
commands["dependabot"] = script.Program(dependabot, nil, 100*time.Millisecond)
return commands
}