move tests to where they belong

This commit is contained in:
Aleksey Kladov 2019-03-25 14:28:04 +03:00
parent e9af69d9db
commit 309716cffe
4 changed files with 32 additions and 44 deletions

View file

@ -560,6 +560,7 @@ fn unresolved_module_diagnostics() {
//- /lib.rs
mod foo;
mod bar;
mod baz {}
//- /foo.rs
",
)

View file

@ -152,6 +152,9 @@ fn check_struct_shorthand_initialization(
#[cfg(test)]
mod tests {
use test_utils::assert_eq_text;
use insta::assert_debug_snapshot_matches;
use crate::mock_analysis::single_file;
use super::*;
@ -180,6 +183,34 @@ mod tests {
assert_eq_text!(after, &actual);
}
#[test]
fn test_unresolved_module_diagnostic() {
let (analysis, file_id) = single_file("mod foo;");
let diagnostics = analysis.diagnostics(file_id).unwrap();
assert_debug_snapshot_matches!(diagnostics, @r####"[
Diagnostic {
message: "unresolved module",
range: [0; 8),
fix: Some(
SourceChange {
label: "create module",
source_file_edits: [],
file_system_edits: [
CreateFile {
source_root: SourceRootId(
0
),
path: "foo.rs"
}
],
cursor_position: None
}
),
severity: Error
}
]"####);
}
#[test]
fn test_check_unnecessary_braces_in_use_statement() {
check_not_applicable(

View file

@ -1,4 +1,3 @@
use insta::assert_debug_snapshot_matches;
use ra_ide_api::{
mock_analysis::{single_file, single_file_with_position, single_file_with_range, MockAnalysis},
AnalysisChange, CrateGraph, Edition::Edition2018, Query, NavigationTarget,
@ -6,21 +5,6 @@ use ra_ide_api::{
};
use ra_syntax::SmolStr;
#[test]
fn test_unresolved_module_diagnostic() {
let (analysis, file_id) = single_file("mod foo;");
let diagnostics = analysis.diagnostics(file_id).unwrap();
assert_debug_snapshot_matches!("unresolved_module_diagnostic", &diagnostics);
}
// FIXME: move this test to hir
#[test]
fn test_unresolved_module_diagnostic_no_diag_for_inline_mode() {
let (analysis, file_id) = single_file("mod foo {}");
let diagnostics = analysis.diagnostics(file_id).unwrap();
assert!(diagnostics.is_empty());
}
#[test]
fn test_resolve_crate_root() {
let mock = MockAnalysis::with_files(

View file

@ -1,28 +0,0 @@
---
created: "2019-01-22T14:45:01.486985900+00:00"
creator: insta@0.4.0
expression: "&diagnostics"
source: "crates\\ra_ide_api\\tests\\test\\main.rs"
---
[
Diagnostic {
message: "unresolved module",
range: [0; 8),
fix: Some(
SourceChange {
label: "create module",
source_file_edits: [],
file_system_edits: [
CreateFile {
source_root: SourceRootId(
0
),
path: "foo.rs"
}
],
cursor_position: None
}
),
severity: Error
}
]