Skip to content

Commit

Permalink
fix(dockertestx): Ignore not found container (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
sawadashota authored May 16, 2021
1 parent dc78bca commit d186536
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions dockertestx/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,13 @@ func New(opt PoolOption) (*Pool, error) {
states := make(stateList, 0, 3)

if opt.StateStore != nil {
_ = json.NewDecoder(opt.StateStore).Decode(&states)
for i := range states {
states[i].r, _ = pool.ContainerByName(states[i].ContainerName)
if states[i].r == nil {
states[i].r, err = pool.RunWithOptions(&dockertest.RunOptions{
Name: states[i].ContainerName,
Repository: states[i].Repository,
Tag: states[i].Tag,
Env: states[i].Env,
})
if err != nil {
return nil, errors.WithMessage(err, "failed to create lost container from saved state")
}
ds := make(stateList, 0, 3)
_ = json.NewDecoder(opt.StateStore).Decode(&ds)
for i := range ds {
ds[i].r, _ = pool.ContainerByName(ds[i].ContainerName)
if ds[i].r != nil {
// ignore not found container
states = append(states, ds[i])
}
}
}
Expand Down

0 comments on commit d186536

Please sign in to comment.