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

golang-migrate / migrate / 10757516114

08 Sep 2024 05:58AM UTC coverage: 56.319%. Remained the same
10757516114

push

github

web-flow
Merge pull request #1153 from joschi/fix-docker-imports

fix(tests): fix Docker imports

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

54 existing lines in 2 files now uncovered.

4559 of 8095 relevant lines covered (56.32%)

63.9 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/dhui/dktest"
9
        "github.com/docker/docker/api/types/image"
10
        "github.com/docker/docker/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()
×
22
        dc, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("1.41"))
×
23
        if err != nil {
×
24
                return err
×
25
        }
×
26
        defer func() {
×
27
                if err := dc.Close(); err != nil && retErr == nil {
×
UNCOV
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, image.RemoveOptions{Force: true, PruneChildren: true}); err != nil {
×
38
                return err
×
UNCOV
39
        }
×
UNCOV
40
        return nil
×
41
}
42

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

×
47
        for i, spec := range specs {
×
48
                spec := spec // capture range variable, see https://goo.gl/60w3p2
×
49

×
50
                // Only test against one version in short mode
×
51
                // TODO: order is random, maybe always pick first version instead?
×
52
                if i > 0 && testing.Short() {
×
53
                        t.Logf("Skipping %v in short mode", spec.ImageName)
×
54
                } else {
×
55
                        t.Run(spec.ImageName, func(t *testing.T) {
×
56
                                t.Parallel()
×
UNCOV
57
                                dktest.Run(t, spec.ImageName, spec.Options, testFunc)
×
UNCOV
58
                        })
×
59
                }
60
        }
61
}
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