mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 15:05:28 +02:00
58 lines
1.0 KiB
Go
58 lines
1.0 KiB
Go
package analyzer
|
|
|
|
import (
|
|
"config-lsp/handlers/wireguard/parser"
|
|
"config-lsp/utils"
|
|
"testing"
|
|
)
|
|
|
|
func TestMultipleIntefaces(t *testing.T) {
|
|
content := utils.Dedent(`
|
|
[Interface]
|
|
PrivateKey = abc
|
|
|
|
[Interface]
|
|
PrivateKey = def
|
|
`)
|
|
p := parser.CreateWireguardParser()
|
|
p.ParseFromString(content)
|
|
|
|
diagnostics := Analyze(p)
|
|
|
|
if len(diagnostics) == 0 {
|
|
t.Errorf("Expected diagnostic errors, got %d", len(diagnostics))
|
|
}
|
|
}
|
|
|
|
func TestInvalidValue(t *testing.T) {
|
|
content := utils.Dedent(`
|
|
[Interface]
|
|
DNS = nope
|
|
`)
|
|
p := parser.CreateWireguardParser()
|
|
p.ParseFromString(content)
|
|
|
|
diagnostics := Analyze(p)
|
|
|
|
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
|
|
`)
|
|
p := parser.CreateWireguardParser()
|
|
p.ParseFromString(content)
|
|
|
|
diagnostics := Analyze(p)
|
|
|
|
if len(diagnostics) == 0 {
|
|
t.Errorf("Expected diagnostic errors, got %d", len(diagnostics))
|
|
}
|
|
}
|