MCPcopy
hub / github.com/go-git/go-git / TestParseWithInvalidExpression

Method TestParseWithInvalidExpression

internal/revision/parser_test.go:187–212  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

185}
186
187func (s *ParserSuite) TestParseWithInvalidExpression(c *C) {
188 datas := map[string]error{
189 "..": &ErrInvalidRevision{`must not start with "."`},
190 "master^1master": &ErrInvalidRevision{`reference must be defined once at the beginning`},
191 "master^1@{2016-12-16T21:42:47Z}": &ErrInvalidRevision{`"@" statement is not valid, could be : <refname>@{<ISO-8601 date>}, @{<ISO-8601 date>}`},
192 "master^1@{1}": &ErrInvalidRevision{`"@" statement is not valid, could be : <refname>@{<n>}, @{<n>}`},
193 "master@{-1}": &ErrInvalidRevision{`"@" statement is not valid, could be : @{-<n>}`},
194 "master^1@{upstream}": &ErrInvalidRevision{`"@" statement is not valid, could be : <refname>@{upstream}, @{upstream}, <refname>@{u}, @{u}`},
195 "master^1@{u}": &ErrInvalidRevision{`"@" statement is not valid, could be : <refname>@{upstream}, @{upstream}, <refname>@{u}, @{u}`},
196 "master^1@{push}": &ErrInvalidRevision{`"@" statement is not valid, could be : <refname>@{push}, @{push}`},
197 "^1": &ErrInvalidRevision{`"~" or "^" statement must have a reference defined at the beginning`},
198 "^{/test}": &ErrInvalidRevision{`"~" or "^" statement must have a reference defined at the beginning`},
199 "~1": &ErrInvalidRevision{`"~" or "^" statement must have a reference defined at the beginning`},
200 "master:/test": &ErrInvalidRevision{`":" statement is not valid, could be : :/<regexp>`},
201 "master:0:README": &ErrInvalidRevision{`":" statement is not valid, could be : :<n>:<path>`},
202 "^{/": &ErrInvalidRevision{`missing "}" in ^{<data>} structure`},
203 "~@{": &ErrInvalidRevision{`missing "}" in @{<data>} structure`},
204 "@@{{0": &ErrInvalidRevision{`missing "}" in @{<data>} structure`},
205 }
206
207 for s, e := range datas {
208 parser := NewParser(bytes.NewBufferString(s))
209 _, err := parser.Parse()
210 c.Assert(err, DeepEquals, e)
211 }
212}
213
214func (s *ParserSuite) TestParseAtWithValidExpression(c *C) {
215 tim, _ := time.Parse("2006-01-02T15:04:05Z", "2016-12-16T21:42:47Z")

Callers

nothing calls this directly

Calls 2

ParseMethod · 0.95
NewParserFunction · 0.70

Tested by

no test coverage detected