config-lsp/handlers/wireguard/analyzer_test.go
2024-08-18 17:05:11 +02:00

54 lines
988 B
Go

package wireguard
import "testing"
func TestMultipleIntefaces(t *testing.T) {
content := dedent(`
[Interface]
PrivateKey = abc
[Interface]
PrivateKey = def
`)
parser := createWireguardParser()
parser.parseFromString(content)
diagnostics := parser.analyze()
if len(diagnostics) == 0 {
t.Errorf("Expected diagnostic errors, got %d", len(diagnostics))
}
}
func TestInvalidValue(t *testing.T) {
content := dedent(`
[Interface]
DNS = nope
`)
parser := createWireguardParser()
parser.parseFromString(content)
diagnostics := parser.analyze()
if len(diagnostics) == 0 {
t.Errorf("Expected diagnostic errors, got %d", len(diagnostics))
}
}
func TestDuplicateProperties(t *testing.T) {
content := dedent(`
[Interface]
PrivateKey = abc
DNS = 1.1.1.1
PrivateKey = def
`)
parser := createWireguardParser()
parser.parseFromString(content)
diagnostics := parser.analyze()
if len(diagnostics) == 0 {
t.Errorf("Expected diagnostic errors, got %d", len(diagnostics))
}
}