File tree Expand file tree Collapse file tree 3 files changed +67
-2
lines changed Expand file tree Collapse file tree 3 files changed +67
-2
lines changed Original file line number Diff line number Diff line change 24
24
run : go build -v ./...
25
25
26
26
- name : Test
27
- run : go test -race -cover -coverprofile="coverage.txt " -covermode=atomic ./...
27
+ run : go test -race -cover -coverprofile="coverage.out " -covermode=atomic ./...
28
28
29
- - name : Coverage
29
+ - name : Codecov
30
30
uses : codecov/codecov-action@v1
Original file line number Diff line number Diff line change
1
+ package gonfig
2
+
3
+ import (
4
+ "errors"
5
+ "reflect"
6
+ "testing"
7
+
8
+ "github.com/stretchr/testify/assert"
9
+ )
10
+
11
+ func TestInvalidInputError_Error (t * testing.T ) {
12
+ var i interface {}
13
+ var s struct {}
14
+ var sp * struct {}
15
+ num := 2
16
+
17
+ tests := []struct {
18
+ input interface {}
19
+ expected string
20
+ }{
21
+ {
22
+ input : nil ,
23
+ expected : "<nil>" ,
24
+ },
25
+ {
26
+ input : i ,
27
+ expected : "<nil>" ,
28
+ },
29
+ {
30
+ input : s ,
31
+ expected : "non-pointer type" ,
32
+ },
33
+ {
34
+ input : sp ,
35
+ expected : "nil pointer" ,
36
+ },
37
+ {
38
+ input : & num ,
39
+ expected : "non-struct type" ,
40
+ },
41
+ }
42
+
43
+ for _ , tc := range tests {
44
+ ie := InvalidInputError {
45
+ Value : reflect .ValueOf (tc .input ),
46
+ }
47
+
48
+ assert .EqualError (t , & ie , "gonfig: invalid input: " + tc .expected )
49
+ }
50
+ }
51
+
52
+ func TestConfigErrors_Error (t * testing.T ) {
53
+ ce := ConfigErrors {
54
+ errors .New ("first" ),
55
+ errors .New ("second" ),
56
+ errors .New ("third" ),
57
+ }
58
+
59
+ assert .EqualError (t , ce , "gonfig:\n * first\n * second\n * third" )
60
+ }
Original file line number Diff line number Diff line change
1
+ foo :
2
+ &foo
3
+ bar : baz
4
+
1
5
config :
2
6
host : golang.org
7
+ << : *foo
3
8
4
9
custom_key : custom
You can’t perform that action at this time.
0 commit comments