summaryrefslogtreecommitdiff
path: root/libnetwork
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2022-10-01 16:47:24 +0200
committerSebastiaan van Stijn <github@gone.nl>2023-04-26 22:49:49 +0200
commitfc1e69891498c4fa9ae70a0e7b8275e857f3a5d0 (patch)
tree4a27e6f803729ecfd1d44fc76168640549b01292 /libnetwork
parent55d18b7db99ebb695c28d4adb45fa09704ee21e3 (diff)
downloaddocker-fc1e69891498c4fa9ae70a0e7b8275e857f3a5d0.tar.gz
libnetwork/resolvconf: fix TestGet() testing wrong path
The test was assuming that the "source" file was always "/etc/resolv.conf", but the `Get()` function uses `Path()` to find the location of resolv.conf, which may be different. While at it, also changed some `t.Fatalf()` to `t.Errorf()`, and renamed some variables for clarity. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'libnetwork')
-rw-r--r--libnetwork/resolvconf/resolvconf_linux_test.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/libnetwork/resolvconf/resolvconf_linux_test.go b/libnetwork/resolvconf/resolvconf_linux_test.go
index 797825e4b4..563f04fdec 100644
--- a/libnetwork/resolvconf/resolvconf_linux_test.go
+++ b/libnetwork/resolvconf/resolvconf_linux_test.go
@@ -7,19 +7,19 @@ import (
)
func TestGet(t *testing.T) {
- resolvConfUtils, err := Get()
+ actual, err := Get()
if err != nil {
t.Fatal(err)
}
- resolvConfSystem, err := os.ReadFile("/etc/resolv.conf")
+ expected, err := os.ReadFile(Path())
if err != nil {
t.Fatal(err)
}
- if string(resolvConfUtils.Content) != string(resolvConfSystem) {
- t.Fatalf("/etc/resolv.conf and GetResolvConf have different content.")
+ if !bytes.Equal(actual.Content, expected) {
+ t.Errorf("%s and GetResolvConf have different content.", Path())
}
- if !bytes.Equal(resolvConfUtils.Hash, hashData(resolvConfSystem)) {
- t.Fatalf("/etc/resolv.conf and GetResolvConf have different hashes.")
+ if !bytes.Equal(actual.Hash, hashData(expected)) {
+ t.Errorf("%s and GetResolvConf have different hashes.", Path())
}
}