def test_get_resolv_conf_file(self): resolv_conf_content = "nameserver 1.2.3.4" resolv_conf_path = self.temp_dir / "fake-resolv.conf" with resolv_conf_path.open("w") as resolv_conf_file: print(resolv_conf_content, file=resolv_conf_file, end="") self.assertThat(_get_resolv_conf_content(resolv_conf_path), Equals(resolv_conf_content))
def test_get_resolv_conf_file_from_environment_preferred(self): self.useFixture( fixtures.EnvironmentVariable( "SNAPCRAFT_BUILD_ENVIRONMENT_NAMESERVER", "9.9.9.9")) resolv_conf_content = "nameserver 1.2.3.4" resolv_conf_path = self.temp_dir / "fake-resolv.conf" with resolv_conf_path.open("w") as resolv_conf_file: print(resolv_conf_content, file=resolv_conf_file, end="") resolv_conf_path = self.temp_dir / "fake-resolv.conf" self.assertThat(_get_resolv_conf_content(resolv_conf_path), Equals("nameserver 9.9.9.9"))
def test_get_resolv_conf_file_default_nameserver(self): resolv_conf_path = self.temp_dir / "fake-resolv.conf" self.assertThat(_get_resolv_conf_content(resolv_conf_path), Equals("nameserver 1.1.1.1"))