• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

golang-migrate / migrate / 28357587916

29 Jun 2026 08:04AM UTC coverage: 54.412% (-0.02%) from 54.432%
28357587916

Pull #1402

github

Faisal, Ahmad Mu'min (contracted)
chore: cleanup unused comments
Pull Request #1402: fix(security): migrate docker/docker to moby/moby modules (BlackDuck Polaris findings)

0 of 28 new or added lines in 2 files covered. (0.0%)

4378 of 8046 relevant lines covered (54.41%)

48.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/dktesting/dktesting.go
1
package dktesting
2

3
import (
4
        "context"
5
        "fmt"
6
        "testing"
7

8
        "github.com/containerd/errdefs"
9
        "github.com/dhui/dktest"
10
        "github.com/moby/moby/client"
11
)
12

13
// ContainerSpec holds Docker testing setup specifications
14
type ContainerSpec struct {
15
        ImageName string
16
        Options   dktest.Options
17
}
18

19
// Cleanup cleanups the ContainerSpec after a test run by removing the ContainerSpec's image
20
func (s *ContainerSpec) Cleanup() (retErr error) {
×
21
        // copied from dktest.RunContext()
×
NEW
22
        dc, err := client.New(client.FromEnv, client.WithAPIVersion("1.41"))
×
23
        if err != nil {
×
24
                return err
×
25
        }
×
26
        defer func() {
×
27
                if err := dc.Close(); err != nil && retErr == nil {
×
28
                        retErr = fmt.Errorf("error closing Docker client: %w", err)
×
29
                }
×
30
        }()
31
        cleanupTimeout := s.Options.CleanupTimeout
×
32
        if cleanupTimeout <= 0 {
×
33
                cleanupTimeout = dktest.DefaultCleanupTimeout
×
34
        }
×
35
        ctx, timeoutCancelFunc := context.WithTimeout(context.Background(), cleanupTimeout)
×
36
        defer timeoutCancelFunc()
×
NEW
37
        if _, err := dc.ImageRemove(ctx, s.ImageName, client.ImageRemoveOptions{Force: true, PruneChildren: true}); err != nil {
×
NEW
38
                if errdefs.IsNotFound(err) {
×
NEW
39
                        return nil
×
NEW
40
                }
×
41
                return err
×
42
        }
43
        return nil
×
44
}
45

46
// ParallelTest runs Docker tests in parallel
47
func ParallelTest(t *testing.T, specs []ContainerSpec,
48
        testFunc func(*testing.T, dktest.ContainerInfo)) {
×
49

×
50
        for i, spec := range specs {
×
51
                spec := spec // capture range variable, see https://goo.gl/60w3p2
×
52

×
53
                // Only test against one version in short mode
×
54
                // TODO: order is random, maybe always pick first version instead?
×
55
                if i > 0 && testing.Short() {
×
56
                        t.Logf("Skipping %v in short mode", spec.ImageName)
×
57
                } else {
×
58
                        t.Run(spec.ImageName, func(t *testing.T) {
×
59
                                t.Parallel()
×
60
                                dktest.Run(t, spec.ImageName, spec.Options, testFunc)
×
61
                        })
×
62
                }
63
        }
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc