This file is indexed.

/usr/share/gocode/src/github.com/fhs/go-netrc/netrc/netrc_test.go is in golang-github-fhs-go-netrc-dev 0.0~git20160504.0.4ffed54-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
62
// Copyright © 2010 Fazlul Shahriar <fshahriar@gmail.com>.
// See LICENSE file for license details.

package netrc_test

import (
	. "github.com/fhs/go-netrc/netrc"
	"testing"
)

var expectedMach = []*Machine{
	&Machine{"mail.google.com", "joe@gmail.com", "somethingSecret", "gmail"},
	&Machine{"ray", "demo", "mypassword", ""},
	&Machine{"", "anonymous", "joe@example.com", ""},
}
var expectedMac = Macros{
	"allput": "put src/*",
}

func eqMach(a *Machine, b *Machine) bool {
	return a.Name == b.Name &&
		a.Login == b.Login &&
		a.Password == b.Password &&
		a.Account == b.Account
}

func TestParse(t *testing.T) {
	mach, mac, err := ParseFile("example.netrc")
	if err != nil {
		t.Fatal(err)
	}

	for i, e := range expectedMach {
		if !eqMach(e, mach[i]) {
			t.Errorf("bad machine; expected %v, got %v\n", e, mach[i])
		}
	}

	for k, v := range expectedMac {
		if v != mac[k] {
			t.Errorf("bad macro for %s; expected %s, got %s\n", k, v, mac[k])
		}
	}
}

func TestFindMachine(t *testing.T) {
	m, err := FindMachine("example.netrc", "ray")
	if err != nil {
		t.Fatal(err)
	}
	if !eqMach(m, expectedMach[1]) {
		t.Errorf("bad machine; expected %v, got %v\n", expectedMach[1], m)
	}

	m, err = FindMachine("example.netrc", "non.existent")
	if err != nil {
		t.Fatal(err)
	}
	if !eqMach(m, expectedMach[2]) {
		t.Errorf("bad machine; expected %v, got %v\n", expectedMach[2], m)
	}
}