open-nomad/drivers/shared/resolvconf/mount_unix_test.go
Mahmood Ali f4450db775 tests: use system path
On host with systemd-resolved, we copy /run/systemd/resolve/resolv.conf
actually.
2020-10-01 10:23:19 -04:00

32 lines
641 B
Go

// +build !windows
package resolvconf
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
dresolvconf "github.com/docker/libnetwork/resolvconf"
"github.com/stretchr/testify/require"
)
func Test_copySystemDNS(t *testing.T) {
require := require.New(t)
data, err := ioutil.ReadFile(dresolvconf.Path())
require.NoError(err)
tmp, err := ioutil.TempDir("", "copySystemDNS_Test")
require.NoError(err)
defer os.RemoveAll(tmp)
dest := filepath.Join(tmp, "resolv.conf")
require.NoError(copySystemDNS(dest))
require.FileExists(dest)
tmpResolv, err := ioutil.ReadFile(dest)
require.NoError(err)
require.Equal(data, tmpResolv)
}