Clean up so that lint would pass

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
This commit is contained in:
Goutham Veeramachaneni 2019-12-27 13:07:33 +00:00 committed by Ben Kochie
parent ae6594c606
commit 219d3672b7
No known key found for this signature in database
GPG Key ID: C646B23C9E3245F1
3 changed files with 22 additions and 18 deletions

View File

@ -16,10 +16,11 @@ package main
import (
"fmt"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
"testing"
"gopkg.in/yaml.v2"
)
func TestNoConfig(t *testing.T) {
@ -87,8 +88,8 @@ func TestLoadBadFile(t *testing.T) {
os.Remove(tmpfile.Name())
config, err := LoadConfig(tmpfile.Name())
if config != nil {
t.Errorf("Expected no config upon non-existent file.")
if err == nil || config != nil {
t.Errorf("Expected no config upon non-existent file. err: %s", err)
}
}
@ -106,8 +107,8 @@ func TestLoadBadConfig(t *testing.T) {
tmpfile.Close()
config, err := LoadConfig(tmpfile.Name())
if config != nil {
t.Errorf("Expected no config upon bad config.")
if err == nil || config != nil {
t.Errorf("Expected no config upon bad config. err: %s", err)
}
}

7
irc.go
View File

@ -16,11 +16,12 @@ package main
import (
"crypto/tls"
irc "github.com/fluffle/goirc/client"
"log"
"strconv"
"strings"
"time"
irc "github.com/fluffle/goirc/client"
)
const (
@ -131,7 +132,7 @@ func (notifier *IRCNotifier) HandleKick(nick string, channel string) {
return
}
state, ok := notifier.JoinedChannels[channel]
if ok == false {
if !ok {
log.Printf("Being kicked out of non-joined channel (%s), ignoring", channel)
return
}
@ -149,7 +150,7 @@ func (notifier *IRCNotifier) CleanupChannels() {
}
func (notifier *IRCNotifier) JoinChannel(channel *IRCChannel) {
if _, joined := notifier.JoinedChannels[channel.Name]; joined == true {
if _, joined := notifier.JoinedChannels[channel.Name]; joined {
return
}
log.Printf("Joining %s", channel.Name)

View File

@ -17,7 +17,6 @@ package main
import (
"bufio"
"fmt"
irc "github.com/fluffle/goirc/client"
"io"
"log"
"net"
@ -26,17 +25,19 @@ import (
"sync"
"testing"
"time"
irc "github.com/fluffle/goirc/client"
)
type LineHandlerFunc func(*bufio.ReadWriter, *irc.Line) error
func h_USER(conn *bufio.ReadWriter, line *irc.Line) error {
func hUSER(conn *bufio.ReadWriter, line *irc.Line) error {
r := fmt.Sprintf(":example.com 001 %s :Welcome\n", line.Args[0])
conn.WriteString(r)
return nil
_, err := conn.WriteString(r)
return err
}
func h_QUIT(conn *bufio.ReadWriter, line *irc.Line) error {
func hQUIT(conn *bufio.ReadWriter, line *irc.Line) error {
return fmt.Errorf("client asked to terminate")
}
@ -62,8 +63,8 @@ func (s *testServer) setDefaultHandlers() {
if s.lineHandlers == nil {
s.lineHandlers = make(map[string]LineHandlerFunc)
}
s.lineHandlers["USER"] = h_USER
s.lineHandlers["QUIT"] = h_QUIT
s.lineHandlers["USER"] = hUSER
s.lineHandlers["QUIT"] = hQUIT
}
func (s *testServer) getHandler(cmd string) LineHandlerFunc {
@ -457,7 +458,7 @@ func TestSendAlertDisconnected(t *testing.T) {
testStep.Wait()
log.Printf("=Server= Completing session")
holdUserStep.Done()
return h_USER(conn, line)
return hUSER(conn, line)
}
server.SetHandler("USER", holdUser)
@ -675,12 +676,13 @@ func TestGhostAndIdentify(t *testing.T) {
usedNick.Add(1)
unregisteredNickHandler.Add(1)
nickHandler := func(conn *bufio.ReadWriter, line *irc.Line) error {
var err error
if line.Args[0] == "foo" {
conn.WriteString(":example.com 433 * foo :nick in use\n")
_, err = conn.WriteString(":example.com 433 * foo :nick in use\n")
}
usedNick.Done()
unregisteredNickHandler.Wait()
return nil
return err
}
server.SetHandler("NICK", nickHandler)