From 84b6f0715703de9f1d2ce02e497d9cab785e1f5d Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Mon, 7 Jul 2025 20:58:02 -0400 Subject: Add code actions for importing packages from collections --- src/testing/testing.odin | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/testing') 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) -- cgit v1.2.3