]> Cypherpunks.ru repositories - netrc.git/blob - netrc_test.go
Initial commit
[netrc.git] / netrc_test.go
1 package netrc
2
3 import (
4         "reflect"
5         "testing"
6 )
7
8 var testNetrc = `
9 machine incomplete
10 password none
11
12 machine api.github.com
13   login user
14   password pwd
15
16 machine incomlete.host
17   login justlogin
18
19 machine test.host
20 login user2
21 password pwd2
22
23 machine oneline login user3 password pwd3
24
25 machine ignore.host macdef ignore
26   login nobody
27   password nothing
28
29 machine hasmacro.too macdef ignore-next-lines login user4 password pwd4
30   login nobody
31   password nothing
32
33 default
34 login anonymous
35 password gopher@golang.org
36
37 machine after.default
38 login oops
39 password too-late-in-file
40 `
41
42 func TestParse(t *testing.T) {
43         lines := Parse(testNetrc)
44         want := []Line{
45                 {"api.github.com", "user", "pwd"},
46                 {"test.host", "user2", "pwd2"},
47                 {"oneline", "user3", "pwd3"},
48                 {"hasmacro.too", "user4", "pwd4"},
49         }
50         if !reflect.DeepEqual(lines, want) {
51                 t.Errorf("have %q\nwant %q", lines, want)
52         }
53 }