-
Notifications
You must be signed in to change notification settings - Fork 62
/
cli_test.go
60 lines (57 loc) · 1.23 KB
/
cli_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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package jwtauth
import (
"errors"
"testing"
)
func TestParseHelp(t *testing.T) {
tests := []struct {
name string
err string
summary string
detail string
}{
{
err: "",
summary: "",
detail: "",
},
{
err: "No error text",
summary: "",
detail: "",
},
{
err: "Errors: * This is an error.",
summary: "Login error",
detail: "This is an error.",
},
{
err: "Errors: * Vault login failed. Because of reasons.",
summary: "Vault login failed.",
detail: "Because of reasons.",
},
{
err: "Errors: * Token verification failed. Because of reasons.",
summary: "Token verification failed.",
detail: "Because of reasons.",
},
{
err: "Errors: * No response from provider. Because of reasons.",
summary: "No response from provider.",
detail: "Because of reasons.",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
s, d := parseError(errors.New(test.err))
if s != test.summary {
t.Fatalf("expected summary: %q, got: %q", test.summary, s)
}
if d != test.detail {
t.Fatalf("expected detail: %q, got: %q", test.detail, d)
}
})
}
}