mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 23:45:27 +02:00
54 lines
988 B
Go
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))
|
|
}
|
|
}
|