-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtype_token_type_test.go
74 lines (68 loc) · 1.66 KB
/
type_token_type_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//go:build unit
package gitlab_test
import (
"testing"
"github.com/stretchr/testify/assert"
gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab"
)
func TestTokenType(t *testing.T) {
var tests = []struct {
expected gitlab.TokenType
input string
err bool
}{
{
expected: gitlab.TokenTypePersonal,
input: gitlab.TokenTypePersonal.String(),
},
{
expected: gitlab.TokenTypeGroup,
input: gitlab.TokenTypeGroup.String(),
},
{
expected: gitlab.TokenTypeProject,
input: gitlab.TokenTypeProject.String(),
},
{
expected: gitlab.TokenTypeUserServiceAccount,
input: gitlab.TokenTypeUserServiceAccount.String(),
},
{
expected: gitlab.TokenTypeGroupServiceAccount,
input: gitlab.TokenTypeGroupServiceAccount.String(),
},
{
expected: gitlab.TokenTypePipelineProjectTrigger,
input: gitlab.TokenTypePipelineProjectTrigger.String(),
},
{
expected: gitlab.TokenTypeProjectDeploy,
input: gitlab.TokenTypeProjectDeploy.String(),
},
{
expected: gitlab.TokenTypeGroupDeploy,
input: gitlab.TokenTypeGroupDeploy.String(),
},
{
expected: gitlab.TokenTypeUnknown,
input: "unknown",
err: true,
},
{
expected: gitlab.TokenTypeUnknown,
input: "unknown",
err: true,
},
}
for _, test := range tests {
t.Logf("assert parse(%s) = %s (err: %v)", test.input, test.expected, test.err)
val, err := gitlab.TokenTypeParse(test.input)
assert.EqualValues(t, test.expected, val)
assert.EqualValues(t, test.expected.Value(), test.expected.String())
if test.err {
assert.ErrorIs(t, err, gitlab.ErrUnknownTokenType)
} else {
assert.NoError(t, err)
}
}
}