summaryrefslogtreecommitdiffhomepage
path: root/net/dns/ini_test.go
blob: 0e5b966a8674f8eba6347d2f8e9da7cf1fbcbdcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause

//go:build windows

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{
				"automount": {"enabled": "true", "root": "/mnt/"},
				"network":   {"generateResolvConf": "false"},
			},
		},
	}
	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)
		}
	}
}