Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/test/pkg/integration/closer.go
2498 views
1
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package integration
6
7
import (
8
"testing"
9
)
10
11
func DeferCloser(t *testing.T, closer []func() error) {
12
// Much "defer", we run the closer in reversed order. This way, we can
13
// append to this list quite naturally, and still break things down in
14
// the correct order.
15
t.Cleanup(func() {
16
for i := len(closer) - 1; i >= 0; i-- {
17
err := closer[i]()
18
if err != nil {
19
t.Logf("cleanup failed: %q", err)
20
}
21
}
22
})
23
}
24
25