Code review comment for ~peter-sabaini/charm-sudo-pair:fix-tmpfiles

Revision history for this message
Peter Sabaini (peter-sabaini) wrote :

LOL, indeed I meant to really compare something in the test. Thanks for the catch -- please take a look?

On 13.01.20 19:29, Drew Freiberger wrote:
> Review: Approve
>
> I've run unit tests with my suggestion on testing the content below. Content fine as is, but would recommend the additional test.
>
> Thanks for the commit!
>
> Diff comments:
>
>> diff --git a/tests/unit/test_libsudopair.py b/tests/unit/test_libsudopair.py
>> index ecd1e41..d983900 100644
>> --- a/tests/unit/test_libsudopair.py
>> +++ b/tests/unit/test_libsudopair.py
>> @@ -147,6 +147,13 @@ class TestSudoPairHelper():
>> sph.create_socket_dir()
>> assert os.path.exists(tmpdir.join('/var/run/sudo_pair'))
>>
>> + def test_create_tmpfiles_conf(self, sph, tmpdir):
>> + sph.create_tmpfiles_conf()
>> + expected_content = ''
>
> I'd really like to see this check some amount of the content of the return to make sure the function is still able to be properly mocked out with the read/write.
>
> expected_content = "d {} 0755 - - -\n".format(sph.socket_dir)
>
>> + with open(tmpdir.join('/usr/lib/tmpfiles.d/sudo_pair.conf')) as f:
>> + content = f.read()
>> + assert expected_content in content
>
> assert expected_content == content
>
>> +
>> def test_install_sudo_pair_so(self, sph, tmpdir):
>> sph.install_sudo_pair_so()
>> assert filecmp.cmp('./files/sudo_pair.so', tmpdir.join('/usr/lib/sudo/sudo_pair.so'))
>
>

« Back to merge proposal