From fc1e69891498c4fa9ae70a0e7b8275e857f3a5d0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 1 Oct 2022 16:47:24 +0200 Subject: 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 --- libnetwork/resolvconf/resolvconf_linux_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libnetwork') 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()) } } -- cgit v1.2.1