Skip to content

Commit c39a56d

Browse files
committed
test: add testing for workspace hover
1 parent b72de4c commit c39a56d

8 files changed

+85
-1
lines changed

src/workspace/hover.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@ impl ProtoLanguageState {
2020

2121
#[cfg(test)]
2222
mod test {
23+
use insta::assert_yaml_snapshot;
24+
25+
use crate::state::ProtoLanguageState;
26+
2327
#[test]
24-
fn workspace_test_hover() {}
28+
fn workspace_test_hover() {
29+
let a_uri = "file://input/workspace_test_hover/a.proto".parse().unwrap();
30+
let b_uri = "file://input/workspace_test_hover/b.proto".parse().unwrap();
31+
let c_uri = "file://input/workspace_test_hover/c.proto".parse().unwrap();
32+
33+
let a = include_str!("input/workspace_test_hover/a.proto");
34+
let b = include_str!("input/workspace_test_hover/b.proto");
35+
let c = include_str!("input/workspace_test_hover/c.proto");
36+
37+
let mut state = ProtoLanguageState::new();
38+
state.upsert_file(&a_uri, a.to_owned());
39+
state.upsert_file(&b_uri, b.to_owned());
40+
state.upsert_file(&c_uri, c.to_owned());
41+
42+
assert_yaml_snapshot!(state.hover("com.library", "Author"));
43+
assert_yaml_snapshot!(state.hover("com.library", "Author.Address"));
44+
assert_yaml_snapshot!(state.hover("com.library", "com.utility.Foobar.Baz"));
45+
assert_yaml_snapshot!(state.hover("com.utility", "com.library.Baz"));
46+
}
2547
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
syntax = "proto3";
2+
3+
package com.library;
4+
5+
import "c.proto";
6+
7+
// A Book is a book
8+
message Book {
9+
Author author = 1;
10+
Author.Address foo = 2;
11+
com.utility.FooBar.Baz z = 3;
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
syntax = "proto3";
2+
3+
package com.library;
4+
5+
// A author is a author
6+
message Author {
7+
string name = 1;
8+
9+
// Address is a Address
10+
message Address {
11+
int64 zip = 1;
12+
}
13+
14+
Address foo = 2;
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
syntax = "proto3";
2+
3+
package com.utility;
4+
5+
// A foobar is a dummy message
6+
message Foobar {
7+
8+
// What is baz?
9+
message Baz {
10+
int64 b = 1;
11+
}
12+
13+
Baz a = 2;
14+
}
15+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: src/workspace/hover.rs
3+
expression: "state.hover(\"com.library\", \"Author.Address\")"
4+
---
5+
- Address is a Address
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: src/workspace/hover.rs
3+
expression: "state.hover(\"com.library\", \"com.utility.Foobar.Baz\")"
4+
---
5+
- What is baz?
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: src/workspace/hover.rs
3+
expression: "state.hover(\"com.utility\", \"com.library.Baz\")"
4+
---
5+
[]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: src/workspace/hover.rs
3+
expression: "state.hover(\"com.library\", \"Author\")"
4+
---
5+
- A author is a author

0 commit comments

Comments
 (0)