2020-04-28 03:11:06 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package resolvconf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2020-10-01 13:58:39 +00:00
|
|
|
dresolvconf "github.com/docker/libnetwork/resolvconf"
|
2020-04-28 03:11:06 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_copySystemDNS(t *testing.T) {
|
|
|
|
require := require.New(t)
|
2020-10-01 13:58:39 +00:00
|
|
|
data, err := ioutil.ReadFile(dresolvconf.Path())
|
2020-04-28 03:11:06 +00:00
|
|
|
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)
|
|
|
|
}
|