Myzel394 a0dca94b9d
refactor(server): Refactor Wireguard config; Improve completions + bunch of other stuff
Signed-off-by: Myzel394 <github.7a2op@simplelogin.co>
2025-03-16 00:23:54 +01:00

66 lines
1.1 KiB
Go

package analyzer
import (
"config-lsp/handlers/wireguard"
"config-lsp/handlers/wireguard/ast"
"config-lsp/utils"
"testing"
)
func TestMultipleIntefaces(t *testing.T) {
content := utils.Dedent(`
[Interface]
PrivateKey = abc
[Interface]
PrivateKey = def
`)
d := &wireguard.WGDocument{
Config: ast.NewWGConfig(),
}
d.Config.Parse(content)
diagnostics := Analyze(d)
if !(len(diagnostics) > 0) {
t.Errorf("Expected diagnostic errors, got %d", len(diagnostics))
}
}
func TestInvalidValue(t *testing.T) {
content := utils.Dedent(`
[Interface]
DNS = nope
`)
d := &wireguard.WGDocument{
Config: ast.NewWGConfig(),
}
d.Config.Parse(content)
diagnostics := Analyze(d)
if !(len(diagnostics) > 0) {
t.Errorf("Expected diagnostic errors, got %d", len(diagnostics))
}
}
func TestDuplicateProperties(t *testing.T) {
content := utils.Dedent(`
[Interface]
PrivateKey = abc
DNS = 1.1.1.1
PrivateKey = def
`)
d := &wireguard.WGDocument{
Config: ast.NewWGConfig(),
}
d.Config.Parse(content)
diagnostics := Analyze(d)
if !(len(diagnostics) > 0) {
t.Errorf("Expected diagnostic errors, got %d", len(diagnostics))
}
}