1package lsp
 2
 3import (
 4	"context"
 5	"testing"
 6
 7	"github.com/charmbracelet/crush/internal/config"
 8)
 9
10func TestPowernapClient(t *testing.T) {
11	ctx := context.Background()
12
13	// Create a simple config for testing
14	cfg := config.LSPConfig{
15		Command:   "echo", // Use echo as a dummy command that won't fail
16		Args:      []string{"hello"},
17		FileTypes: []string{"go"},
18		Env:       map[string]string{},
19	}
20
21	// Test creating a powernap client - this will likely fail with echo
22	// but we can still test the basic structure
23	client, err := New(ctx, "test", cfg)
24	if err != nil {
25		// Expected to fail with echo command, skip the rest
26		t.Skipf("Powernap client creation failed as expected with dummy command: %v", err)
27		return
28	}
29
30	// If we get here, test basic interface methods
31	if client.GetName() != "test" {
32		t.Errorf("Expected name 'test', got '%s'", client.GetName())
33	}
34
35	if !client.HandlesFile("test.go") {
36		t.Error("Expected client to handle .go files")
37	}
38
39	if client.HandlesFile("test.py") {
40		t.Error("Expected client to not handle .py files")
41	}
42
43	// Test server state
44	client.SetServerState(StateReady)
45	if client.GetServerState() != StateReady {
46		t.Error("Expected server state to be StateReady")
47	}
48
49	// Clean up - expect this to fail with echo command
50	if err := client.Close(t.Context()); err != nil {
51		// Expected to fail with echo command
52		t.Logf("Close failed as expected with dummy command: %v", err)
53	}
54}