Skip to content

Commit 0f8013f

Browse files
committed
fix: redact file paths from test
1 parent 9d63252 commit 0f8013f

10 files changed

+316
-87
lines changed

Cargo.lock

Lines changed: 122 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ pkg-config = "0.3"
3232
clap = { version = "4.5", features = ["derive"] }
3333

3434
[dev-dependencies]
35-
insta = { version = "1.43", features = ["yaml"] }
35+
insta = { version = "1.43", features = ["yaml", "redactions"] }

src/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
};
66
use tracing::info;
77

8-
use async_lsp::lsp_types::ProgressParamsValue;
8+
use async_lsp::lsp_types::{DocumentSymbol, ProgressParamsValue};
99
use async_lsp::lsp_types::{
1010
CompletionItem, CompletionItemKind, Location, OneOf, PublishDiagnosticsParams, Url,
1111
WorkspaceSymbol,
@@ -108,7 +108,7 @@ impl ProtoLanguageState {
108108

109109
fn collect_workspace_symbols(
110110
&self,
111-
doc_symbol: &async_lsp::lsp_types::DocumentSymbol,
111+
doc_symbol: &DocumentSymbol,
112112
uri: &Url,
113113
query: &str,
114114
container_name: Option<String>,

src/workspace/definition.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ mod test {
6060
use crate::context::jumpable::Jumpable;
6161
use std::path::PathBuf;
6262

63-
use insta::assert_yaml_snapshot;
63+
use insta::{assert_yaml_snapshot};
6464

6565
use crate::config::Config;
6666
use crate::state::ProtoLanguageState;
@@ -107,13 +107,9 @@ mod test {
107107
Jumpable::Import("c.proto".to_owned()),
108108
);
109109

110-
assert_eq!(loc.len(), 1);
111-
assert!(
112-
loc[0]
113-
.uri
114-
.to_file_path()
115-
.unwrap()
116-
.ends_with(ipath[0].join("c.proto"))
117-
)
110+
assert_yaml_snapshot!(loc, {"[0].uri" => insta::dynamic_redaction(|c, _| {
111+
assert!(c.as_str().unwrap().ends_with("c.proto"));
112+
"file://<redacted>/c.proto".to_string()
113+
})});
118114
}
119115
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
source: src/workspace/definition.rs
3+
expression: loc
4+
---
5+
- uri: "file://<redacted>/c.proto"
6+
range:
7+
start:
8+
line: 0
9+
character: 0
10+
end:
11+
line: 0
12+
character: 0

src/workspace/snapshots/protols__workspace__workspace_symbol__test__all_symbols.snap

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@
22
source: src/workspace/workspace_symbol.rs
33
expression: all_symbols
44
---
5-
- name: Address
6-
kind: 23
7-
containerName: Author
8-
location:
9-
uri: "file:///home/runner/work/protols/protols/src/workspace/input/b.proto"
10-
range:
11-
start:
12-
line: 9
13-
character: 3
14-
end:
15-
line: 11
16-
character: 4
175
- name: Address
186
kind: 23
197
containerName: Author
@@ -26,17 +14,6 @@ expression: all_symbols
2614
end:
2715
line: 11
2816
character: 4
29-
- name: Author
30-
kind: 23
31-
location:
32-
uri: "file:///home/runner/work/protols/protols/src/workspace/input/b.proto"
33-
range:
34-
start:
35-
line: 5
36-
character: 0
37-
end:
38-
line: 14
39-
character: 1
4017
- name: Author
4118
kind: 23
4219
location:
@@ -48,18 +25,6 @@ expression: all_symbols
4825
end:
4926
line: 14
5027
character: 1
51-
- name: Baz
52-
kind: 23
53-
containerName: Foobar
54-
location:
55-
uri: "file:///home/runner/work/protols/protols/src/workspace/input/c.proto"
56-
range:
57-
start:
58-
line: 8
59-
character: 3
60-
end:
61-
line: 10
62-
character: 4
6328
- name: Baz
6429
kind: 23
6530
containerName: Foobar
@@ -83,17 +48,6 @@ expression: all_symbols
8348
end:
8449
line: 14
8550
character: 1
86-
- name: Foobar
87-
kind: 23
88-
location:
89-
uri: "file:///home/runner/work/protols/protols/src/workspace/input/c.proto"
90-
range:
91-
start:
92-
line: 5
93-
character: 0
94-
end:
95-
line: 13
96-
character: 1
9751
- name: Foobar
9852
kind: 23
9953
location:
@@ -105,25 +59,3 @@ expression: all_symbols
10559
end:
10660
line: 13
10761
character: 1
108-
- name: SomeSecret
109-
kind: 23
110-
location:
111-
uri: "file:///home/runner/work/protols/protols/src/workspace/input/inner/secret/y.proto"
112-
range:
113-
start:
114-
line: 5
115-
character: 0
116-
end:
117-
line: 7
118-
character: 1
119-
- name: Why
120-
kind: 23
121-
location:
122-
uri: "file:///home/runner/work/protols/protols/src/workspace/input/inner/x.proto"
123-
range:
124-
start:
125-
line: 7
126-
character: 0
127-
end:
128-
line: 11
129-
character: 1
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
source: src/workspace/workspace_symbol.rs
3+
expression: author_symbols
4+
---
5+
- name: Author
6+
kind: 23
7+
location:
8+
uri: "file://<redacted>/src/workspace/input/b.proto"
9+
range:
10+
start:
11+
line: 5
12+
character: 0
13+
end:
14+
line: 14
15+
character: 1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
source: src/workspace/workspace_symbol.rs
3+
expression: address_symbols
4+
---
5+
- name: Address
6+
kind: 23
7+
containerName: Author
8+
location:
9+
uri: "file://<redacted>/src/workspace/input/b.proto"
10+
range:
11+
start:
12+
line: 9
13+
character: 3
14+
end:
15+
line: 11
16+
character: 4

0 commit comments

Comments
 (0)