Pārlūkot izejas kodu

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>
Sebastiaan van Stijn 2 gadi atpakaļ
vecāks
revīzija
fc1e698914
1 mainītis faili ar 6 papildinājumiem un 6 dzēšanām
  1. 6 6
      libnetwork/resolvconf/resolvconf_linux_test.go

+ 6 - 6
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())
 	}
 }