(t *testing.T)
| 81 | } |
| 82 | |
| 83 | func TestSourceParser_ExpectCorrectAliases(t *testing.T) { |
| 84 | type Expected struct { |
| 85 | aliases map[string]string |
| 86 | err error |
| 87 | } |
| 88 | |
| 89 | type Case struct { |
| 90 | input string |
| 91 | expected Expected |
| 92 | } |
| 93 | |
| 94 | cases := []Case{ |
| 95 | { |
| 96 | input: ".", |
| 97 | expected: Expected{ |
| 98 | aliases: map[string]string{}, |
| 99 | err: nil, |
| 100 | }, |
| 101 | }, |
| 102 | { |
| 103 | input: ". AS cwd", |
| 104 | expected: Expected{ |
| 105 | aliases: map[string]string{"cwd": "."}, |
| 106 | err: nil, |
| 107 | }, |
| 108 | }, |
| 109 | { |
| 110 | input: "., -.bar, ~/foo AS foo", |
| 111 | expected: Expected{ |
| 112 | aliases: map[string]string{"foo": "~/foo"}, |
| 113 | err: nil, |
| 114 | }, |
| 115 | }, |
| 116 | |
| 117 | { |
| 118 | input: "-.bar AS bar", |
| 119 | expected: Expected{err: errors.New("cannot alias excluded directory .bar")}, |
| 120 | }, |
| 121 | { |
| 122 | input: "", |
| 123 | expected: Expected{err: io.ErrUnexpectedEOF}, |
| 124 | }, |
| 125 | { |
| 126 | input: "foo AS", |
| 127 | expected: Expected{err: io.ErrUnexpectedEOF}, |
| 128 | }, |
| 129 | } |
| 130 | |
| 131 | for _, c := range cases { |
| 132 | sources := make(map[string][]string, 0) |
| 133 | aliases := make(map[string]string, 0) |
| 134 | |
| 135 | p := &parser{tokenizer: tokenizer.NewTokenizer(c.input)} |
| 136 | err := p.parseSourceList(&sources, &aliases) |
| 137 | |
| 138 | if c.expected.err == nil { |
| 139 | if err != nil { |
| 140 | t.Fatalf("\nExpected no error\n Got %v", err) |
nothing calls this directly
no test coverage detected