Skip to content

Commit

Permalink
Reorganize LSP tests (FuelLabs#4015)
Browse files Browse the repository at this point in the history
## Description
This PR simply reorganizes tests, no new code has been added. Previously
the tests were in `server.rs` but have now been moved to a dedicated
`tests` folder.

Done in preparation for working on FuelLabs#3989 

---------

Co-authored-by: Sophie Dankel <[email protected]>
  • Loading branch information
JoshuaBatty and sdankel authored Feb 8, 2023
1 parent 7e861e4 commit 0503e8f
Show file tree
Hide file tree
Showing 51 changed files with 1,490 additions and 1,432 deletions.
15 changes: 14 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sway-lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tracing = "0.1"

[dev-dependencies]
assert-json-diff = "2.0"
async-trait = "0.1"
dirs = "4.0"
futures = { version = "0.3", default-features = false, features = ["std", "async-await"] }
tower = { version = "0.4.12", default-features = false, features = ["util"] }
sway-lsp-test-utils = { path = "tests/utils" }
tower = { version = "0.4.12", default-features = false, features = ["util"] }
6 changes: 3 additions & 3 deletions sway-lsp/src/capabilities/on_enter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn get_comment_workspace_edit(
#[cfg(test)]
mod tests {
use super::*;
use crate::utils::test::get_absolute_path;
use sway_lsp_test_utils::get_absolute_path;
use tower_lsp::lsp_types::{
AnnotatedTextEdit, TextDocumentContentChangeEvent, VersionedTextDocumentIdentifier,
};
Expand Down Expand Up @@ -128,7 +128,7 @@ mod tests {

#[test]
fn get_comment_workspace_edit_double_slash_indented() {
let path = get_absolute_path("sway-lsp/test/fixtures/diagnostics/dead_code/src/main.sw");
let path = get_absolute_path("sway-lsp/tests/fixtures/diagnostics/dead_code/src/main.sw");
let uri = Url::from_file_path(path.clone()).unwrap();
let text_document =
TextDocument::build_from_path(path.as_str()).expect("failed to build document");
Expand Down Expand Up @@ -165,7 +165,7 @@ mod tests {

#[test]
fn get_comment_workspace_edit_triple_slash_paste() {
let path = get_absolute_path("sway-lsp/test/fixtures/diagnostics/dead_code/src/main.sw");
let path = get_absolute_path("sway-lsp/tests/fixtures/diagnostics/dead_code/src/main.sw");
let uri = Url::from_file_path(path.clone()).unwrap();
let text_document =
TextDocument::build_from_path(path.as_str()).expect("failed to build document");
Expand Down
5 changes: 2 additions & 3 deletions sway-lsp/src/core/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,12 @@ struct EditText<'text> {

#[cfg(test)]
mod tests {
use crate::utils::test::get_absolute_path;

use super::*;
use sway_lsp_test_utils::get_absolute_path;

#[test]
fn build_from_path_returns_text_document() {
let path = get_absolute_path("sway-lsp/test/fixtures/cats.txt");
let path = get_absolute_path("sway-lsp/tests/fixtures/cats.txt");
let result = TextDocument::build_from_path(&path);
assert!(result.is_ok(), "result = {result:?}");
}
Expand Down
8 changes: 4 additions & 4 deletions sway-lsp/src/core/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,12 @@ impl Session {
#[cfg(test)]
mod tests {
use super::*;
use crate::utils::test::{get_absolute_path, get_url};
use sway_lsp_test_utils::{get_absolute_path, get_url};

#[test]
fn store_document_returns_empty_tuple() {
let session = Session::new();
let path = get_absolute_path("sway-lsp/test/fixtures/cats.txt");
let path = get_absolute_path("sway-lsp/tests/fixtures/cats.txt");
let document = TextDocument::build_from_path(&path).unwrap();
let result = Session::store_document(&session, document);
assert!(result.is_ok());
Expand All @@ -479,7 +479,7 @@ mod tests {
#[test]
fn store_document_returns_document_already_stored_error() {
let session = Session::new();
let path = get_absolute_path("sway-lsp/test/fixtures/cats.txt");
let path = get_absolute_path("sway-lsp/tests/fixtures/cats.txt");
let document = TextDocument::build_from_path(&path).unwrap();
Session::store_document(&session, document).expect("expected successfully stored");
let document = TextDocument::build_from_path(&path).unwrap();
Expand All @@ -491,7 +491,7 @@ mod tests {
#[test]
fn parse_project_returns_manifest_file_not_found() {
let session = Session::new();
let dir = get_absolute_path("sway-lsp/test/fixtures");
let dir = get_absolute_path("sway-lsp/tests/fixtures");
let uri = get_url(&dir);
let result =
Session::parse_project(&session, &uri).expect_err("expected ManifestFileNotFound");
Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod capabilities;
pub mod config;
mod core;
pub mod error;
mod server;
pub mod server;
mod traverse;
pub mod utils;
use server::Backend;
Expand Down
Loading

0 comments on commit 0503e8f

Please sign in to comment.