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>
This commit is contained in:
parent
55d18b7db9
commit
fc1e698914
1 changed files with 6 additions and 6 deletions
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue