test: restore bridge coverage gate
Rust CI vsg-bridge-ls passed CI.
MadGobblins/vsg-bridge-ls/pipeline/head This commit looks good
Details
Rust CI vsg-bridge-ls passed CI.
MadGobblins/vsg-bridge-ls/pipeline/head This commit looks good
Details
This commit is contained in:
parent
0c296d5070
commit
45aa8928b1
|
|
@ -1422,6 +1422,76 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
/// Forged correction commands cannot bypass current document state checks.
|
||||
#[tokio::test]
|
||||
async fn rejects_corrections_for_invalid_document_state() {
|
||||
let runner = Arc::new(MockRunner::successful(EMPTY_DIAGNOSTICS));
|
||||
let (service, _socket) = LspService::new(move |client| {
|
||||
Backend::new(client, runner.clone(), Vec::new()).with_experimental_rule_fix(true)
|
||||
});
|
||||
let uri =
|
||||
tower_lsp::lsp_types::Url::parse("file:///tmp/example.vhd").expect("valid test URI");
|
||||
|
||||
let execute = |version, correction| ExecuteCommandParams {
|
||||
command: APPLY_CORRECTION.to_owned(),
|
||||
arguments: vec![json!({
|
||||
"schema_version": CORRECTION_COMMAND_SCHEMA_VERSION,
|
||||
"uri": uri,
|
||||
"version": version,
|
||||
"correction": correction
|
||||
})],
|
||||
work_done_progress_params: Default::default(),
|
||||
};
|
||||
|
||||
assert!(tower_lsp::LanguageServer::execute_command(
|
||||
service.inner(),
|
||||
execute(1, json!({"kind": "all"}))
|
||||
)
|
||||
.await
|
||||
.is_err());
|
||||
|
||||
service.inner().documents.write().await.insert(
|
||||
uri.clone(),
|
||||
Document {
|
||||
text: "entity demo is".to_owned(),
|
||||
version: 2,
|
||||
diagnostics: Vec::new(),
|
||||
analysis_complete: false,
|
||||
},
|
||||
);
|
||||
for parameters in [
|
||||
execute(1, json!({"kind": "all"})),
|
||||
execute(2, json!({"kind": "all"})),
|
||||
] {
|
||||
assert!(
|
||||
tower_lsp::LanguageServer::execute_command(service.inner(), parameters)
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
service
|
||||
.inner()
|
||||
.documents
|
||||
.write()
|
||||
.await
|
||||
.get_mut(&uri)
|
||||
.expect("open test document")
|
||||
.analysis_complete = true;
|
||||
for correction in [
|
||||
json!({"kind": "rules", "selectors": []}),
|
||||
json!({"kind": "rules", "selectors": [{"rule": "", "line": 1}]}),
|
||||
json!({"kind": "rules", "selectors": [{"rule": "rule_001", "line": 0}]}),
|
||||
] {
|
||||
assert!(tower_lsp::LanguageServer::execute_command(
|
||||
service.inner(),
|
||||
execute(2, correction)
|
||||
)
|
||||
.await
|
||||
.is_err());
|
||||
}
|
||||
}
|
||||
|
||||
/// The debug action reports runtime and document metadata without source text.
|
||||
#[tokio::test]
|
||||
async fn displays_opt_in_debug_state() {
|
||||
|
|
@ -2137,12 +2207,22 @@ mod tests {
|
|||
let result = request_code_actions(
|
||||
&mut service,
|
||||
serde_json::to_value(&published.diagnostics).expect("serialize diagnostics"),
|
||||
json!(["quickfix"]),
|
||||
json!(["source.fixAll.vsg"]),
|
||||
)
|
||||
.await;
|
||||
|
||||
assert_eq!(result.as_array().expect("action list").len(), 1);
|
||||
assert_eq!(result[0]["command"]["command"], APPLY_CORRECTION);
|
||||
let response = tower_lsp::LanguageServer::execute_command(
|
||||
service.inner(),
|
||||
execute_parameters(&result[0]),
|
||||
)
|
||||
.await;
|
||||
|
||||
assert!(response.is_ok());
|
||||
assert!(timeout(Duration::from_millis(20), socket.next())
|
||||
.await
|
||||
.is_err());
|
||||
}
|
||||
|
||||
/// Correction failures are shown to the user and yield no unsafe edit.
|
||||
|
|
|
|||
Loading…
Reference in New Issue