reckless: properly remove entry from reckless sources
Fixes a bug introduced in 6163138420 which
avoided gratuitous rewrites of the lightningd config
This commit is contained in:
committed by
Christian Decker
parent
f5ddb89d83
commit
c043bf2255
@@ -101,7 +101,8 @@ def get_reckless_node(node_factory):
|
||||
|
||||
def check_stderr(stderr):
|
||||
def output_okay(out):
|
||||
for warning in ['[notice]', 'WARNING:', 'npm WARN', 'npm notice']:
|
||||
for warning in ['[notice]', 'WARNING:', 'npm WARN',
|
||||
'npm notice', 'DEPRECATION:']:
|
||||
if out.startswith(warning):
|
||||
return True
|
||||
return False
|
||||
@@ -135,6 +136,35 @@ def test_sources(node_factory):
|
||||
n = get_reckless_node(node_factory)
|
||||
r = reckless(["source", "-h"], dir=n.lightning_dir)
|
||||
assert r.returncode == 0
|
||||
r = reckless(["source", "list"], dir=n.lightning_dir)
|
||||
print(r.stdout)
|
||||
assert r.returncode == 0
|
||||
print(n.lightning_dir)
|
||||
reckless_dir = Path(n.lightning_dir) / 'reckless'
|
||||
print(dir(reckless_dir))
|
||||
assert (reckless_dir / '.sources').exists()
|
||||
print(os.listdir(reckless_dir))
|
||||
print(reckless_dir / '.sources')
|
||||
r = reckless([f"--network={NETWORK}", "-v", "source", "add",
|
||||
"tests/data/recklessrepo/lightningd/testplugfail"],
|
||||
dir=n.lightning_dir)
|
||||
r = reckless([f"--network={NETWORK}", "-v", "source", "add",
|
||||
"tests/data/recklessrepo/lightningd/testplugpass"],
|
||||
dir=n.lightning_dir)
|
||||
with open(reckless_dir / '.sources') as sources:
|
||||
contents = [c.strip() for c in sources.readlines()]
|
||||
print('contents:', contents)
|
||||
assert 'https://github.com/lightningd/plugins' in contents
|
||||
assert "tests/data/recklessrepo/lightningd/testplugfail" in contents
|
||||
assert "tests/data/recklessrepo/lightningd/testplugpass" in contents
|
||||
r = reckless([f"--network={NETWORK}", "-v", "source", "remove",
|
||||
"tests/data/recklessrepo/lightningd/testplugfail"],
|
||||
dir=n.lightning_dir)
|
||||
with open(reckless_dir / '.sources') as sources:
|
||||
contents = [c.strip() for c in sources.readlines()]
|
||||
print('contents:', contents)
|
||||
assert "tests/data/recklessrepo/lightningd/testplugfail" not in contents
|
||||
assert "tests/data/recklessrepo/lightningd/testplugpass" in contents
|
||||
|
||||
|
||||
def test_search(node_factory):
|
||||
|
||||
@@ -474,10 +474,10 @@ class Config():
|
||||
# The white space is getting excessive.
|
||||
remove_these_lines.append(n)
|
||||
continue
|
||||
if not addline:
|
||||
if not addline and not write_required:
|
||||
return
|
||||
# No write necessary if addline is already in config.
|
||||
if not write_required:
|
||||
if addline and not write_required:
|
||||
for line in original:
|
||||
if line.strip() == addline.strip():
|
||||
return
|
||||
@@ -490,7 +490,7 @@ class Config():
|
||||
conf_write.write(f'\n{l.strip()}')
|
||||
else:
|
||||
conf_write.write(l.strip())
|
||||
if addline.strip() == l.strip():
|
||||
if addline and addline.strip() == l.strip():
|
||||
# addline is idempotent
|
||||
line_exists = True
|
||||
if not line_exists:
|
||||
|
||||
Reference in New Issue
Block a user