-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2176 from crazy-max/fix-builder-creation
driver(container): fix conditional statement for error handling
- Loading branch information
Showing
4 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package tests | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/moby/buildkit/util/testutil/integration" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func createCmd(sb integration.Sandbox, opts ...cmdOpt) (string, error) { | ||
opts = append([]cmdOpt{withArgs("create")}, opts...) | ||
cmd := buildxCmd(sb, opts...) | ||
out, err := cmd.CombinedOutput() | ||
return string(out), err | ||
} | ||
|
||
var createTests = []func(t *testing.T, sb integration.Sandbox){ | ||
testCreateMemoryLimit, | ||
} | ||
|
||
func testCreateMemoryLimit(t *testing.T, sb integration.Sandbox) { | ||
if sb.Name() != "docker-container" { | ||
t.Skip("only testing for docker-container driver") | ||
} | ||
|
||
var builderName string | ||
t.Cleanup(func() { | ||
if builderName == "" { | ||
return | ||
} | ||
out, err := rmCmd(sb, withArgs(builderName)) | ||
require.NoError(t, err, out) | ||
}) | ||
|
||
out, err := createCmd(sb, withArgs("--driver", "docker-container", "--driver-opt", "network=host", "--driver-opt", "memory=1g")) | ||
require.NoError(t, err, out) | ||
builderName = strings.TrimSpace(out) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package tests | ||
|
||
import ( | ||
"github.com/moby/buildkit/util/testutil/integration" | ||
) | ||
|
||
func rmCmd(sb integration.Sandbox, opts ...cmdOpt) (string, error) { | ||
opts = append([]cmdOpt{withArgs("rm")}, opts...) | ||
cmd := buildxCmd(sb, opts...) | ||
out, err := cmd.CombinedOutput() | ||
return string(out), err | ||
} |