Skip to content
  • Sami Hiltunen's avatar
    Automatically clean up testhelper.Context · 6c91c8e8
    Sami Hiltunen authored
    testhelper.Context() currently return a cancellation function as a
    second return value. Majority of the tests do not need to explicitly
    cancel the context but they simply defer its cancellation to clean up
    after the test. Given this, we can reduce the test verbosity and make
    testhelper.Context easier to compose by removing the unnecessary second
    return value. This adds a t.Cleanup function to automatically cancel the
    context at the end of the tests and omits the returned cancellation
    function.
    
    Tests which simply `defer cancel()` have had the extra call removed. Some
    tests explicitly call the cancellation, and these tests have been modified
    to add context.WithCancel around the testhelper.Context call. There are a
    few loctions where testing.TB was passed down to test helpers that create the
    context.
    6c91c8e8