Skip to content
This repository was archived by the owner on Jul 21, 2021. It is now read-only.

Commit 7f34fcb

Browse files
committed
gofmt: Fix formatting
1 parent 97943c8 commit 7f34fcb

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

auth.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ var (
1414
)
1515

1616
type AuthUser struct {
17-
username string
18-
passwordHash string
17+
username string
18+
passwordHash string
1919
allowedAddresses []string
2020
}
2121

@@ -48,8 +48,8 @@ func parseLine(line string) *AuthUser {
4848
}
4949

5050
user := AuthUser{
51-
username: parts[0],
52-
passwordHash: parts[1],
51+
username: parts[0],
52+
passwordHash: parts[1],
5353
allowedAddresses: nil,
5454
}
5555

auth_test.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ func stringsEqual(a, b []string) bool {
88
if len(a) != len(b) {
99
return false
1010
}
11-
for i, _ := range a {
11+
for i := range a {
1212
if a[i] != b[i] {
1313
return false
1414
}
@@ -18,50 +18,50 @@ func stringsEqual(a, b []string) bool {
1818

1919
func TestParseLine(t *testing.T) {
2020
var tests = []struct {
21-
name string
21+
name string
2222
expectFail bool
23-
line string
24-
username string
25-
addrs []string
23+
line string
24+
username string
25+
addrs []string
2626
}{
2727
{
28-
name: "Empty line",
28+
name: "Empty line",
2929
expectFail: true,
30-
line: "",
30+
line: "",
3131
},
3232
{
33-
name: "Too few fields",
33+
name: "Too few fields",
3434
expectFail: true,
35-
line: "joe",
35+
line: "joe",
3636
},
3737
{
38-
name: "Too many fields",
38+
name: "Too many fields",
3939
expectFail: true,
40-
line: "joe xxx joe@example.com whatsthis",
40+
line: "joe xxx joe@example.com whatsthis",
4141
},
4242
{
43-
name: "Normal case",
44-
line: "joe xxx joe@example.com",
43+
name: "Normal case",
44+
line: "joe xxx joe@example.com",
4545
username: "joe",
46-
addrs: []string{"joe@example.com"},
46+
addrs: []string{"joe@example.com"},
4747
},
4848
{
49-
name: "No allowed addrs given",
50-
line: "joe xxx",
49+
name: "No allowed addrs given",
50+
line: "joe xxx",
5151
username: "joe",
52-
addrs: []string{},
52+
addrs: []string{},
5353
},
5454
{
55-
name: "Trailing comma",
56-
line: "joe xxx joe@example.com,",
55+
name: "Trailing comma",
56+
line: "joe xxx joe@example.com,",
5757
username: "joe",
58-
addrs: []string{"joe@example.com"},
58+
addrs: []string{"joe@example.com"},
5959
},
6060
{
61-
name: "Multiple allowed addrs",
62-
line: "joe xxx joe@example.com,@foo.example.com",
61+
name: "Multiple allowed addrs",
62+
line: "joe xxx joe@example.com,@foo.example.com",
6363
username: "joe",
64-
addrs: []string{"joe@example.com", "@foo.example.com"},
64+
addrs: []string{"joe@example.com", "@foo.example.com"},
6565
},
6666
}
6767

@@ -77,12 +77,12 @@ func TestParseLine(t *testing.T) {
7777

7878
if user.username != test.username {
7979
t.Errorf("Testcase %d: Incorrect username: expected %v, got %v",
80-
i, test.username, user.username)
80+
i, test.username, user.username)
8181
}
8282

8383
if !stringsEqual(user.allowedAddresses, test.addrs) {
8484
t.Errorf("Testcase %d: Incorrect addresses: expected %v, got %v",
85-
i, test.addrs, user.allowedAddresses)
85+
i, test.addrs, user.allowedAddresses)
8686
}
8787
})
8888
}

main_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ func TestAddrAllowedSingle(t *testing.T) {
2424

2525
func TestAddrAllowedDifferentCase(t *testing.T) {
2626
allowedAddrs := []string{"joe@abc.com"}
27-
testAddrs := []string{
28-
"joe@ABC.com",
29-
"Joe@abc.com",
30-
"JOE@abc.com",
31-
"JOE@ABC.COM",
32-
}
33-
for _, addr := range testAddrs {
34-
if !addrAllowed(addr, allowedAddrs) {
35-
t.Errorf("Address %v not allowed, but should be", addr)
36-
}
37-
}
27+
testAddrs := []string{
28+
"joe@ABC.com",
29+
"Joe@abc.com",
30+
"JOE@abc.com",
31+
"JOE@ABC.COM",
32+
}
33+
for _, addr := range testAddrs {
34+
if !addrAllowed(addr, allowedAddrs) {
35+
t.Errorf("Address %v not allowed, but should be", addr)
36+
}
37+
}
3838
}
3939

4040
func TestAddrAllowedLocal(t *testing.T) {

0 commit comments

Comments
 (0)