(t *testing.T)
| 127 | } |
| 128 | |
| 129 | func TestParseOneAndImport(t *testing.T) { |
| 130 | testParseOne := func(input string) (ServerBlock, error) { |
| 131 | p := testParser(input) |
| 132 | p.Next() // parseOne doesn't call Next() to start, so we must |
| 133 | err := p.parseOne() |
| 134 | return p.block, err |
| 135 | } |
| 136 | |
| 137 | for i, test := range []struct { |
| 138 | input string |
| 139 | shouldErr bool |
| 140 | keys []string |
| 141 | numTokens []int // number of tokens to expect in each segment |
| 142 | }{ |
| 143 | {`localhost`, false, []string{ |
| 144 | "localhost", |
| 145 | }, []int{}}, |
| 146 | |
| 147 | {`localhost |
| 148 | dir1`, false, []string{ |
| 149 | "localhost", |
| 150 | }, []int{1}}, |
| 151 | |
| 152 | { |
| 153 | `localhost:1234 |
| 154 | dir1 foo bar`, false, []string{ |
| 155 | "localhost:1234", |
| 156 | }, []int{3}, |
| 157 | }, |
| 158 | |
| 159 | {`localhost { |
| 160 | dir1 |
| 161 | }`, false, []string{ |
| 162 | "localhost", |
| 163 | }, []int{1}}, |
| 164 | |
| 165 | {`localhost:1234 { |
| 166 | dir1 foo bar |
| 167 | dir2 |
| 168 | }`, false, []string{ |
| 169 | "localhost:1234", |
| 170 | }, []int{3, 1}}, |
| 171 | |
| 172 | {`http://localhost https://localhost |
| 173 | dir1 foo bar`, false, []string{ |
| 174 | "http://localhost", |
| 175 | "https://localhost", |
| 176 | }, []int{3}}, |
| 177 | |
| 178 | {`http://localhost https://localhost { |
| 179 | dir1 foo bar |
| 180 | }`, false, []string{ |
| 181 | "http://localhost", |
| 182 | "https://localhost", |
| 183 | }, []int{3}}, |
| 184 | |
| 185 | {`http://localhost, https://localhost { |
| 186 | dir1 foo bar |
nothing calls this directly
no test coverage detected