add shutdown context unit test

This commit is contained in:
iofq
2024-11-09 15:34:35 -06:00
parent 8436001d5b
commit 840b76228a
2 changed files with 11 additions and 0 deletions

View File

@@ -154,3 +154,13 @@ func (s *DownloaderSuite) TestGetLengthConnectError(c *C) {
c.Assert(err, ErrorMatches, ".*no such host")
}
func (s *DownloaderSuite) TestContextCancel(c *C) {
ctx, cancel := context.WithCancel(s.ctx)
s.ctx = ctx
cancel()
_, err := s.d.GetLength(s.ctx, "http://nosuch.host.invalid./")
c.Assert(err, ErrorMatches, ".*context canceled.*")
}