summaryrefslogtreecommitdiffstats
path: root/tests/lsp_tests/test_lsp_dctrl.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lsp_tests/test_lsp_dctrl.py')
-rw-r--r--tests/lsp_tests/test_lsp_dctrl.py88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/lsp_tests/test_lsp_dctrl.py b/tests/lsp_tests/test_lsp_dctrl.py
index d258e8f..122b929 100644
--- a/tests/lsp_tests/test_lsp_dctrl.py
+++ b/tests/lsp_tests/test_lsp_dctrl.py
@@ -70,3 +70,91 @@ def test_dctrl_hover_doc_field(ls: "LanguageServer") -> None:
)
assert hover_doc is not None and isinstance(hover_doc.contents, MarkupContent)
assert "Determines which architecture" in hover_doc.contents.value
+
+
+def test_dctrl_hover_doc_synopsis(ls: "LanguageServer") -> None:
+ dctrl_uri = "file:///nowhere/debian/control"
+ cursor_pos = put_doc_with_cursor(
+ ls,
+ dctrl_uri,
+ "debian/control",
+ textwrap.dedent(
+ """\
+ Source: foo
+
+ Package: foo
+ Architecture: any
+ Description: super charged<CURSOR> tool with batteries included
+"""
+ ),
+ )
+
+ hover_doc = _debian_control_hover(
+ ls,
+ HoverParams(TextDocumentIdentifier(dctrl_uri), cursor_pos),
+ )
+ assert hover_doc is not None and isinstance(hover_doc.contents, MarkupContent)
+ assert hover_doc.contents.value.startswith("# Package synopsis")
+ assert "super charged tool with batteries included" in hover_doc.contents.value
+
+
+def test_dctrl_hover_doc_substvars(ls: "LanguageServer") -> None:
+ dctrl_uri = "file:///nowhere/debian/control"
+ matching_cases = [
+ "bar (= <CURSOR>${binary:Version})",
+ "bar (= $<CURSOR>{binary:Version})",
+ "bar (= ${binary:Version<CURSOR>})",
+ ]
+ for variant in matching_cases:
+ cursor_pos = put_doc_with_cursor(
+ ls,
+ dctrl_uri,
+ "debian/control",
+ textwrap.dedent(
+ f"""\
+ Source: foo
+
+ Package: foo
+ Architecture: any
+ Depends: bar (= {variant})
+ Description: super charged tool with batteries included
+ """
+ ),
+ )
+
+ hover_doc = _debian_control_hover(
+ ls,
+ HoverParams(TextDocumentIdentifier(dctrl_uri), cursor_pos),
+ )
+ assert hover_doc is not None and isinstance(hover_doc.contents, MarkupContent)
+ assert hover_doc.contents.value.startswith("# Substvar `${binary:Version}`")
+
+ non_matching_cases = [
+ "bar (=<CURSOR> ${binary:Version})",
+ "bar (= ${binary:Version}<CURSOR>)",
+ ]
+ for variant in non_matching_cases:
+ cursor_pos = put_doc_with_cursor(
+ ls,
+ dctrl_uri,
+ "debian/control",
+ textwrap.dedent(
+ f"""\
+ Source: foo
+
+ Package: foo
+ Architecture: any
+ Depends: bar (= {variant})
+ Description: super charged tool with batteries included
+ """
+ ),
+ )
+
+ hover_doc = _debian_control_hover(
+ ls,
+ HoverParams(TextDocumentIdentifier(dctrl_uri), cursor_pos),
+ )
+ provided_doc = ""
+ if hover_doc is not None and isinstance(hover_doc.contents, MarkupContent):
+ provided_doc = hover_doc.contents.value
+ assert not provided_doc.startswith("# Substvar `${binary:Version}`")