mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> (cherry picked from commit 57d737a13c9e7484753d796407582a9a3997d7d2)
40 lines
982 B
Go
40 lines
982 B
Go
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)
|
|
}
|