aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/oauth2/internal/oauth2_test.go
blob: 07d51c433e71e8dceef4c7168ec3c092e1cf11c0 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package internal

import (
	"reflect"
	"strings"
	"testing"
)

func TestParseINI(t *testing.T) {
	tests := []struct {
		ini  string
		want map[string]map[string]string
	}{
		{
			`root = toor
[foo]  
bar = hop
ini = nin
`,
			map[string]map[string]string{
				"":    {"root": "toor"},
				"foo": {"bar": "hop", "ini": "nin"},
			},
		},
		{
			`[empty]
[section]
empty=
`,
			map[string]map[string]string{
				"":        {},
				"empty":   {},
				"section": {"empty": ""},
			},
		},
		{
			`ignore
[invalid
=stuff
;comment=true
`,
			map[string]map[string]string{
				"": {},
			},
		},
	}
	for _, tt := range tests {
		result, err := ParseINI(strings.NewReader(tt.ini))
		if err != nil {
			t.Errorf("ParseINI(%q) error %v, want: no error", tt.ini, err)
			continue
		}
		if !reflect.DeepEqual(result, tt.want) {
			t.Errorf("ParseINI(%q) = %#v, want: %#v", tt.ini, result, tt.want)
		}
	}
}