buildkit/executor/oci/resolvconf_test.go

40 lines
892 B
Go
Raw Normal View History

package oci
import (
"context"
"io/ioutil"
"os"
"testing"
Update docker/docker to master / v21.xx-dev (post libnetwork integration) full diff: https://github.com/docker/docker/compare/v20.10.7..0ad2293d0e5b This applies the same / similar local changes to buildkit as were made in the branch that moby is currently vendoring: https://github.com/moby/buildkit/compare/244e8cde...cpuguy83:update_libnetwork_import Unfortunately, this (again) requires a "replace" rule (probably until we tagged a release with this change). Go mod refuses to pick a version from master, and (without the replace rule), does weird, reverting docker to a very old version, predating the sirupsen rename: > [vendored 4/4] RUN --mount=target=/src,rw --mount=target=/go/pkg/mod,type=cache go mod tidy && go mod vendor && mkdir /out && cp -r go.mod go.sum vendor /out: #10 0.500 go: finding github.com/docker/docker 8dbd90ec00daa26dc45d7da2431c965dec99e8b4 #10 0.599 warning: ignoring symlink /src/examples/kube-consistent-hash #10 1.027 go: github.com/moby/buildkit/util/testutil/integration imports #10 1.027 github.com/docker/docker/testutil/daemon imports #10 1.027 github.com/docker/docker/opts imports #10 1.027 github.com/docker/libnetwork/ipamutils imports #10 1.027 github.com/docker/libnetwork/osl imports #10 1.027 github.com/Sirupsen/logrus: github.com/Sirupsen/logrus@v1.8.1: parsing go.mod: #10 1.027 module declares its path as: github.com/sirupsen/logrus #10 1.027 but was required as: github.com/Sirupsen/logrus ------ error: failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c go mod tidy && go mod vendor && mkdir /out && cp -r go.mod go.sum vendor /out]: exit code: 1 make: *** [vendor] Error 1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-05 15:54:05 +00:00
"github.com/docker/docker/libnetwork/resolvconf"
"github.com/stretchr/testify/require"
)
// TestResolvConfNotExist modifies a global variable
// It must not run in parallel.
func TestResolvConfNotExist(t *testing.T) {
oldResolvconfGet := resolvconfGet
defer func() {
resolvconfGet = oldResolvconfGet
}()
resolvconfGet = func() (*resolvconf.File, error) {
return nil, os.ErrNotExist
}
defaultResolvConf := `
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844`
dir, err := ioutil.TempDir("", "buildkit-test")
require.NoError(t, err)
defer os.RemoveAll(dir)
ctx := context.Background()
p, err := GetResolvConf(ctx, dir, nil, nil)
require.NoError(t, err)
b, err := ioutil.ReadFile(p)
require.NoError(t, err)
require.Equal(t, string(b), defaultResolvConf)
}