2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2021-06-26 00:36:36 +01:00
|
|
|
|
2021-08-05 23:42:39 +01:00
|
|
|
//go:build windows
|
2021-07-22 19:57:34 +01:00
|
|
|
|
2021-06-26 00:36:36 +01:00
|
|
|
package dns
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseIni(t *testing.T) {
|
|
|
|
var tests = []struct {
|
|
|
|
src string
|
|
|
|
want map[string]map[string]string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
src: `# appended wsl.conf file
|
|
|
|
[automount]
|
|
|
|
enabled = true
|
|
|
|
root=/mnt/
|
|
|
|
# added by tailscale
|
|
|
|
[network] # trailing comment
|
|
|
|
generateResolvConf = false # trailing comment`,
|
|
|
|
want: map[string]map[string]string{
|
2021-12-15 16:42:25 +00:00
|
|
|
"automount": {"enabled": "true", "root": "/mnt/"},
|
|
|
|
"network": {"generateResolvConf": "false"},
|
2021-06-26 00:36:36 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, test := range tests {
|
|
|
|
got := parseIni(test.src)
|
|
|
|
if !reflect.DeepEqual(got, test.want) {
|
|
|
|
t.Errorf("for:\n%s\ngot: %v\nwant: %v", test.src, got, test.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|