summaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-07 20:58:02 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-03 12:58:16 -0400
commit84b6f0715703de9f1d2ce02e497d9cab785e1f5d (patch)
tree31a716349719b0004fbffac199d9cd6134040511 /src/testing
parentdd17cd2845eb7fc47a7ac3a5002b032a4bc54fd4 (diff)
Add code actions for importing packages from collections
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing.odin32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/testing/testing.odin b/src/testing/testing.odin
index 1b40c6b..57354e1 100644
--- a/src/testing/testing.odin
+++ b/src/testing/testing.odin
@@ -458,6 +458,38 @@ expect_prepare_rename_range :: proc(t: ^testing.T, src: ^Source, expect_range: c
}
}
+
+expect_action :: proc(t: ^testing.T, src: ^Source, expect_action_names: []string) {
+ setup(src)
+ defer teardown(src)
+
+ input_range := common.Range{start=src.position, end=src.position}
+ actions, ok := server.get_code_actions(src.document, input_range, &src.config)
+ if !ok {
+ log.error("Failed to find actions")
+ }
+
+ if len(expect_action_names) == 0 && len(actions) > 0 {
+ log.errorf("Expected empty actions, but received %v", actions)
+ }
+
+ flags := make([]int, len(expect_action_names), context.temp_allocator)
+
+ for name, i in expect_action_names {
+ for action, j in actions {
+ if action.title == name {
+ flags[i] += 1
+ }
+ }
+ }
+
+ for flag, i in flags {
+ if flag != 1 {
+ log.errorf("Expected action %v, but received %v", expect_action_names[i], actions)
+ }
+ }
+}
+
expect_semantic_tokens :: proc(t: ^testing.T, src: ^Source, expected: []server.SemanticToken) {
setup(src)
defer teardown(src)