Roles
This commit is contained in:
@@ -173,8 +173,12 @@ def test_param_completions_injected_on_param_context():
|
||||
assert "roleDefinitionIds" in labels
|
||||
assert "principalId" in labels
|
||||
assert "principalType" in labels
|
||||
assert items[0]["sortText"].startswith("0_lru_param_")
|
||||
assert items[0]["kind"] == 5 # Field
|
||||
# First item is now the snippet completion
|
||||
assert items[0]["label"] == "⚡ Fill params block"
|
||||
assert items[0]["kind"] == 15 # Snippet
|
||||
# Second item should be a regular param
|
||||
assert items[1]["sortText"].startswith("0_lru_param_")
|
||||
assert items[1]["kind"] == 5 # Field
|
||||
|
||||
|
||||
def test_param_completion_items_have_insert_text():
|
||||
@@ -182,7 +186,12 @@ def test_param_completion_items_have_insert_text():
|
||||
"roleassignments", versions=["1.1.x"], schema=_ROLEASSIGNMENTS_SCHEMA
|
||||
)]
|
||||
items = BicepModuleCatalog.param_completion_items("roleassignments", "1.1.x")
|
||||
for item in items:
|
||||
# First item should be the snippet completion
|
||||
assert items[0]["label"] == "⚡ Fill params block"
|
||||
assert items[0]["insertTextFormat"] == 2
|
||||
assert "principalId" in items[0]["insertText"]
|
||||
# Individual param items should have ": " suffix
|
||||
for item in items[1:]:
|
||||
assert item["insertText"].endswith(": ")
|
||||
|
||||
|
||||
@@ -302,6 +311,24 @@ def test_detect_param_value_context_open_quote():
|
||||
assert ctx["has_open_quote"] is True
|
||||
|
||||
|
||||
def test_detect_param_value_context_in_array():
|
||||
"""Cursor inside array value → param_value context."""
|
||||
lines = [
|
||||
"module myMod 'br/modules:roleassignments:1.1.x' = {",
|
||||
" params: {",
|
||||
" roles: ['KEY_VAULT_", # ← cursor inside array element
|
||||
" }",
|
||||
"}",
|
||||
]
|
||||
session = _make_session_with_doc(URI, lines)
|
||||
# character = len(" roles: ['KEY_VAULT_") = 23
|
||||
ctx = session._detect_context(URI, {"line": 2, "character": 23})
|
||||
assert ctx["type"] == "param_value"
|
||||
assert ctx["module"] == "roleassignments"
|
||||
assert ctx["param"] == "roles"
|
||||
assert ctx["has_open_quote"] is True
|
||||
|
||||
|
||||
def test_param_value_items_from_catalog_allowed():
|
||||
"""environmentType completions come from catalog 'allowed' field."""
|
||||
BicepModuleCatalog._modules = [_make_module(
|
||||
@@ -353,6 +380,24 @@ def test_param_value_items_known_enum_fallback():
|
||||
assert "User" in labels
|
||||
|
||||
|
||||
def test_param_value_items_roles_enum():
|
||||
"""roles parameter uses _KNOWN_ENUMS for Azure role completions."""
|
||||
BicepModuleCatalog._modules = [_make_module(
|
||||
"roleassignments",
|
||||
versions=["1.1.x"],
|
||||
schema={"1.1.x": {"parameters": {
|
||||
"roles": {"type": "array"}, # no 'allowed' in catalog
|
||||
}}},
|
||||
)]
|
||||
items = BicepModuleCatalog.param_value_completion_items(
|
||||
"roleassignments", "1.1.x", "roles"
|
||||
)
|
||||
labels = [i["label"] for i in items]
|
||||
assert "KEY_VAULT_SECRETS_USER" in labels
|
||||
assert "STORAGE_BLOB_DATA_READER" in labels
|
||||
assert "CONTRIBUTOR" in labels
|
||||
|
||||
|
||||
def test_param_value_items_empty_for_free_string():
|
||||
"""A plain string param with no allowed values returns no completions."""
|
||||
BicepModuleCatalog._modules = [_make_module(
|
||||
|
||||
Reference in New Issue
Block a user