aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2018-12-06 20:26:23 +0000
committerFlorian Diebold <[email protected]>2018-12-06 20:32:15 +0000
commit29793e7de978c9f0fa2d46bad624fc49d2506b11 (patch)
tree513b56d0c4757f37fa318b964ac1f630e246680b /crates
parent1dfd06fc8aadd5d621112716fe0e59aed5dfc767 (diff)
Add test for code actions
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/main.rs61
1 files changed, 60 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs
index 63d53fb01..26f5e3f20 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/main.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs
@@ -2,7 +2,9 @@ mod support;
2 2
3use serde_json::json; 3use serde_json::json;
4 4
5use ra_lsp_server::req::{Runnables, RunnablesParams}; 5use ra_lsp_server::req::{Runnables, RunnablesParams, CodeActionRequest, CodeActionParams};
6
7use languageserver_types::{Position, Range, CodeActionContext};
6 8
7use crate::support::project; 9use crate::support::project;
8 10
@@ -116,3 +118,60 @@ fn test_eggs() {}
116 ]) 118 ])
117 ); 119 );
118} 120}
121
122#[test]
123fn test_missing_module_code_action() {
124 let server = project(
125 r#"
126//- Cargo.toml
127[package]
128name = "foo"
129version = "0.0.0"
130
131//- src/lib.rs
132mod bar;
133
134fn main() {}
135"#,
136 );
137 server.wait_for_feedback("workspace loaded");
138 let empty_context = || CodeActionContext {
139 diagnostics: Vec::new(),
140 only: None,
141 };
142 server.request::<CodeActionRequest>(
143 CodeActionParams {
144 text_document: server.doc_id("src/lib.rs"),
145 range: Range::new(Position::new(0, 0), Position::new(0, 7)),
146 context: empty_context(),
147 },
148 json!([
149 {
150 "arguments": [
151 {
152 "cursorPosition": null,
153 "fileSystemEdits": [
154 {
155 "type": "createFile",
156 "uri": "file:///[..]/src/bar.rs"
157 }
158 ],
159 "label": "create module",
160 "sourceFileEdits": []
161 }
162 ],
163 "command": "ra-lsp.applySourceChange",
164 "title": "create module"
165 }
166 ]),
167 );
168
169 server.request::<CodeActionRequest>(
170 CodeActionParams {
171 text_document: server.doc_id("src/lib.rs"),
172 range: Range::new(Position::new(2, 0), Position::new(2, 7)),
173 context: empty_context(),
174 },
175 json!([]),
176 );
177}