-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmain_test.go
49 lines (34 loc) · 1.19 KB
/
main_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
package main
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/alexandear/import-gitlab-commits/internal/testutil"
)
func TestExecute(t *testing.T) {
t.Run("error when wrong GITLAB_TOKEN", func(t *testing.T) {
t.Setenv("GITLAB_TOKEN", "")
err := Execute(testutil.NewLog(t))
require.ErrorContains(t, err, "GITLAB_TOKEN")
})
t.Run("error when wrong GITLAB_BASE_URL", func(t *testing.T) {
t.Setenv("GITLAB_TOKEN", "yourgitlabtoken")
t.Setenv("GITLAB_BASE_URL", ":")
err := Execute(testutil.NewLog(t))
require.ErrorContains(t, err, "GITLAB_BASE_URL")
})
t.Run("error when wrong COMMITTER_NAME", func(t *testing.T) {
t.Setenv("GITLAB_TOKEN", "yourgitlabtoken")
t.Setenv("GITLAB_BASE_URL", "https://gitlab.com")
t.Setenv("COMMITTER_NAME", "")
err := Execute(testutil.NewLog(t))
require.ErrorContains(t, err, "COMMITTER_NAME")
})
t.Run("error when wrong COMMITTER_EMAIL", func(t *testing.T) {
t.Setenv("GITLAB_TOKEN", "yourgitlabtoken")
t.Setenv("GITLAB_BASE_URL", "https://gitlab.com")
t.Setenv("COMMITTER_NAME", "John Doe")
t.Setenv("COMMITTER_EMAIL", "")
err := Execute(testutil.NewLog(t))
require.ErrorContains(t, err, "COMMITTER_EMAIL")
})
}