-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e_test.go
50 lines (40 loc) · 999 Bytes
/
e2e_test.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
43
44
45
46
47
48
49
50
package config
import (
"fmt"
"os"
"testing"
"github.com/alecthomas/kong"
"github.com/stretchr/testify/require"
"gitlab.com/tozd/go/x"
)
func TestE2E(t *testing.T) {
t.Parallel()
if os.Getenv("GITLAB_API_TOKEN") == "" {
t.Skip("GITLAB_API_TOKEN is not available")
}
tempDir := t.TempDir()
projectID, errE := x.InferGitLabProjectID(".")
require.NoError(t, errE, "% -+#.1v", errE)
for _, cmd := range []string{"get", "set"} {
cmd := cmd
t.Run(fmt.Sprintf("case=%s", cmd), func(t *testing.T) {
t.Parallel()
var commands Commands
parser, err := kong.New(&commands,
kong.Vars{
"defaultDocsRef": DefaultDocsRef,
},
kong.Exit(func(code int) {
if code != 0 {
t.Errorf("Kong exited with code %d", code)
}
}),
)
require.NoError(t, err)
ctx, err := parser.Parse([]string{"-C", tempDir, cmd, "-p", projectID})
require.NoError(t, err)
err = ctx.Run(&commands.Globals)
require.NoError(t, err, "% -+#.1v", err)
})
}
}