copy data from static variable instead of use it directly to prevent caching.

also update test cases to verfiy this issue.

Fixes: #994
https://pagure.io/koji/issue/994
This commit is contained in:
Franz Chih-Ping Hsieh 2018-07-19 00:26:01 -04:00 committed by Mike McLean
parent 304b1708c4
commit e25603dd97
4 changed files with 26 additions and 1 deletions

View file

@ -1,6 +1,7 @@
from __future__ import absolute_import
import copy
import mock
import os
try:
import unittest2 as unittest
except ImportError:
@ -37,6 +38,30 @@ class TestRPMDiff(unittest.TestCase):
Rpmdiff.assert_called_once_with('basepath/12/1234/foo', 'basepath/13/1345/bar', ignore='S5TN')
d.textdiff.assert_called_once_with()
def test_rpmdiff_real_target(self):
data_path = os.path.abspath("tests/test_hub/data/rpms")
# the only differences between rpm1 and rpm2 are 1) create time 2) file name
rpm1 = os.path.join(data_path, 'test-pkg-1.0.0-1.el7.noarch.rpm')
rpm2 = os.path.join(data_path, 'test-pkg-1.0.0-1.fc24.noarch.rpm')
diff_output = "..........T /usr/share/test-pkg/test-doc01.txt\n" + \
"..........T /usr/share/test-pkg/test-doc02.txt\n" + \
"..........T /usr/share/test-pkg/test-doc03.txt\n" + \
"..........T /usr/share/test-pkg/test-doc04.txt"
# case 1. no ignore option, timestamp is different
# perform twice check to verify issue: #994
for _ in range(0, 2):
d = koji.rpmdiff.Rpmdiff(rpm1, rpm2)
self.assertEqual(d.textdiff(), diff_output)
# case 2. ignore timestamp, two rpms should be the same
# perform twice check to verify issue: #994
for r in range(0, 2):
d = koji.rpmdiff.Rpmdiff(rpm1, rpm2, ignore='S5TN')
self.assertEqual(d.textdiff(), '')
class TestCheckNoarchRpms(unittest.TestCase):
@mock.patch('kojihub.rpmdiff')
def test_check_noarch_rpms_empty_invocation(self, rpmdiff):