forked from nginxinc/nginx-go-crossplane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors_test.go
42 lines (34 loc) · 826 Bytes
/
errors_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
/**
* Copyright (c) F5, Inc.
*
* This source code is licensed under the Apache License, Version 2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
package crossplane
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestErrorString(t *testing.T) {
t.Parallel()
tf := "test.conf"
tl := 1
var te error
tcs := []struct {
f *string
w string
l *int
e error
exp string
}{
{&tf, "error", &tl, te, "error in test.conf:1"},
{nil, "error", &tl, te, "error in (nofile):1"},
{nil, "error", nil, te, "error in (nofile)"},
{&tf, "error", nil, te, "error in test.conf"},
{nil, "", nil, te, " in (nofile)"},
}
for _, tc := range tcs {
e := &ParseError{File: tc.f, Line: tc.l, What: tc.w, originalErr: tc.e}
assert.Equal(t, tc.exp, e.Error())
}
}