Skip to content

Commit

Permalink
Update tests for showing why line was logged
Browse files Browse the repository at this point in the history
  • Loading branch information
elikoga committed Nov 11, 2024
1 parent 532e643 commit a1f0ee4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/batou/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def deploy(self, predict_only=False):
)
if took_too_long:
output.annotate(
f"{self.host.name} > {self._breadcrumbs} [{self.timer.humanize('total', 'verify', 'update', 'sub')}]"
f"{self.host.name} > {self._breadcrumbs} [{self.timer.humanize('total', 'verify', 'update', 'sub')}] "
+ ", ".join(steps_too_long)
+ " took too long",
)
Expand Down
10 changes: 5 additions & 5 deletions src/batou/lib/tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def test_content_large_diff_logged(output, root):

assert output.backend.output == Ellipsis(
"""\
localhost > MyComponent > Content('work/mycomponent/path')
localhost > MyComponent > Content('work/mycomponent/path'): update
More than 20 lines of diff. Showing first and last 5 lines.
see ... for the full diff.
path ---
Expand Down Expand Up @@ -549,7 +549,7 @@ def test_json_diff(output, root):

assert output.backend.output == Ellipsis(
"""\
localhost > MyComponent > JSONContent('work/mycomponent/target.json')
localhost > MyComponent > JSONContent('work/mycomponent/target.json'): update
target.json ---
target.json +++
target.json @@ -1,3 +1,4 @@
Expand All @@ -574,7 +574,7 @@ def test_json_diff_not_for_sensitive(output, root):

assert output.backend.output == Ellipsis(
"""\
localhost > MyComponent > JSONContent('work/mycomponent/target.json')
localhost > MyComponent > JSONContent('work/mycomponent/target.json'): update
Not showing diff as it contains sensitive data.
"""
)
Expand Down Expand Up @@ -731,7 +731,7 @@ def test_yaml_diff(output, root):

# fmt: off
assert output.backend.output == Ellipsis("""\
localhost > MyComponent > YAMLContent(\'work/mycomponent/target.yaml\')
localhost > MyComponent > YAMLContent(\'work/mycomponent/target.yaml\'): update
target.yaml ---
target.yaml +++
target.yaml @@ -1,3 +1,2 @@
Expand All @@ -757,7 +757,7 @@ def test_yaml_diff_not_for_sensitive(output, root):

assert output.backend.output == Ellipsis(
"""\
localhost > MyComponent > YAMLContent('work/mycomponent/target.yaml')
localhost > MyComponent > YAMLContent('work/mycomponent/target.yaml'): update
Not showing diff as it contains sensitive data.
"""
)
Expand Down
34 changes: 17 additions & 17 deletions src/batou/tests/test_endtoend.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ def test_diff_is_not_shown_for_keys_in_secrets(tmp_path, monkeypatch, capsys):
localhost: Connecting via local (1/1)
================================== Deploying ===================================
localhost: Scheduling component hello ...
localhost > Hello > File('work/hello/hello') > Presence('hello')
localhost > Hello > File('work/hello/hello') > Content('hello')
localhost > Hello > File('work/hello/hello') > Presence('hello'): update
localhost > Hello > File('work/hello/hello') > Content('hello'): update
Not showing diff as it contains sensitive data,
see ...diff for the diff.
localhost > Hello > File('work/hello/other-secrets.yaml') > Presence('other-secrets.yaml')
localhost > Hello > File('work/hello/other-secrets.yaml') > Content('other-secrets.yaml')
localhost > Hello > File('work/hello/other-secrets.yaml') > Presence('other-secrets.yaml'): update
localhost > Hello > File('work/hello/other-secrets.yaml') > Content('other-secrets.yaml'): update
Not showing diff as it contains sensitive data,
see ...diff for the diff.
=================================== Summary ====================================
Expand Down Expand Up @@ -318,29 +318,29 @@ def test_diff_for_keys_in_secrets_overridable(tmp_path, monkeypatch, capsys):
localhost: Connecting via local (1/1)
================================== Deploying ===================================
localhost: Scheduling component sensitivevalues ...
localhost > SensitiveValues > File('work/sensitivevalues/client_ed25519.key') > Presence('client_ed25519.key')
localhost > SensitiveValues > File('work/sensitivevalues/client_ed25519.key') > Content('client_ed25519.key')
localhost > SensitiveValues > File('work/sensitivevalues/client_ed25519.key') > Presence('client_ed25519.key'): update
localhost > SensitiveValues > File('work/sensitivevalues/client_ed25519.key') > Content('client_ed25519.key'): update
Not showing diff as it contains sensitive data,
see ...diff for the diff.
localhost > SensitiveValues > File('work/sensitivevalues/client_ed25519.pub') > Presence('client_ed25519.pub')
localhost > SensitiveValues > File('work/sensitivevalues/client_ed25519.pub') > Content('client_ed25519.pub')
localhost > SensitiveValues > File('work/sensitivevalues/client_ed25519.pub') > Presence('client_ed25519.pub'): update
localhost > SensitiveValues > File('work/sensitivevalues/client_ed25519.pub') > Content('client_ed25519.pub'): update
Not showing diff as it contains sensitive data,
see ...diff for the diff.
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_auto_rsa.pub') > Presence('hostkey_sensitive_auto_rsa.pub')
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_auto_rsa.pub') > Content('hostkey_sensitive_auto_rsa.pub')
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_auto_rsa.pub') > Presence('hostkey_sensitive_auto_rsa.pub'): update
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_auto_rsa.pub') > Content('hostkey_sensitive_auto_rsa.pub'): update
hostkey_sensitive_auto_rsa.pub ---
hostkey_sensitive_auto_rsa.pub +++
hostkey_sensitive_auto_rsa.pub @@ -0,0 +1 @@
hostkey_sensitive_auto_rsa.pub +ssh-rsa ... batou-example-host
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_auto_ed25519.pub') > Presence('hostkey_sensitive_auto_ed25519.pub')
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_auto_ed25519.pub') > Content('hostkey_sensitive_auto_ed25519.pub')
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_auto_ed25519.pub') > Presence('hostkey_sensitive_auto_ed25519.pub'): update
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_auto_ed25519.pub') > Content('hostkey_sensitive_auto_ed25519.pub'): update
Not showing diff as it contains sensitive data,
see ...diff for the diff.
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_masked_rsa.pub') > Presence('hostkey_sensitive_masked_rsa.pub')
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_masked_rsa.pub') > Content('hostkey_sensitive_masked_rsa.pub')
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_masked_rsa.pub') > Presence('hostkey_sensitive_masked_rsa.pub'): update
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_masked_rsa.pub') > Content('hostkey_sensitive_masked_rsa.pub'): update
Not showing diff as it contains sensitive data.
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_clear_ed25519.pub') > Presence('hostkey_sensitive_clear_ed25519.pub')
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_clear_ed25519.pub') > Content('hostkey_sensitive_clear_ed25519.pub')
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_clear_ed25519.pub') > Presence('hostkey_sensitive_clear_ed25519.pub'): update
localhost > SensitiveValues > File('work/sensitivevalues/hostkey_sensitive_clear_ed25519.pub') > Content('hostkey_sensitive_clear_ed25519.pub'): update
hostkey_sensitive_clear_ed25519.pub ---
hostkey_sensitive_clear_ed25519.pub +++
hostkey_sensitive_clear_ed25519.pub @@ -0,0 +1 @@
Expand All @@ -366,7 +366,7 @@ def test_durations_are_shown_for_components():
localhost: Connecting via local (1/1)
================================== Deploying ===================================
localhost: Scheduling component takeslongtime ...
localhost > Takeslongtime [total=...s, verify=...s, update=NaN, sub=NaN]
localhost > Takeslongtime [total=...s, verify=...s, update=NaN, sub=NaN] verify took too long
=================================== Summary ====================================
Deployment took total=...s, connect=...s, deploy=...s
============================= DEPLOYMENT FINISHED ==============================
Expand Down
2 changes: 1 addition & 1 deletion src/batou/tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def test_log_in_component_configure_is_put_out(output, sample_service):
log = "\n".join(c[0][0].strip() for c in output.call_args_list)
assert (
"""\
localhost > Hello
localhost > Hello: update
localhost: <Hello (localhost) "Hello"> verify: asdf=None\
"""
== log
Expand Down

0 comments on commit a1f0ee4

Please sign in to comment.