From 2bb84599ea00fb0a4872ebd45cc5cb9fa173e6cb Mon Sep 17 00:00:00 2001 From: MichaelOultram Date: Mon, 10 Aug 2015 01:19:27 +0100 Subject: [PATCH] Given up on go test, using my own --- .travis.yml | 2 +- main.go | 10 ++++++++-- main_test.go => test.go | 20 +++++++++++--------- 3 files changed, 20 insertions(+), 12 deletions(-) rename main_test.go => test.go (84%) diff --git a/.travis.yml b/.travis.yml index c5ea4fd..a7f2baa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,4 @@ before_install: - bash install-dependencies.sh after_success: - - go test \ No newline at end of file + - mumbledj -server=$MUMBLE_IP -port=$MUMBLE_PORT -username=travis -password=$MUMBLE_PASSWORD -test=true \ No newline at end of file diff --git a/main.go b/main.go index 1dd4907..f59a93c 100644 --- a/main.go +++ b/main.go @@ -193,7 +193,7 @@ func main() { } var address, port, username, password, channel, pemCert, pemKey, accesstokens string - var insecure, verbose bool + var insecure, verbose, test bool flag.StringVar(&address, "server", "localhost", "address for Mumble server") flag.StringVar(&port, "port", "64738", "port for Mumble server") @@ -204,7 +204,8 @@ func main() { flag.StringVar(&pemKey, "key", "", "path to user PEM key for MumbleDJ") flag.StringVar(&accesstokens, "accesstokens", "", "list of access tokens for channel auth") flag.BoolVar(&insecure, "insecure", false, "skip certificate checking") - flag.BoolVar(&verbose, "verbose", false, "prints out debug messages to the console") + flag.BoolVar(&verbose, "verbose", false, "[debug] prints out debug messages to the console") + flag.BoolVar(&test, "test", false, "[debug] tests the features of mumbledj") flag.Parse() dj.config = gumble.Config{ @@ -254,4 +255,9 @@ func main() { } <-dj.keepAlive + + if test { + Test(password, address, port) + kill() + } } diff --git a/main_test.go b/test.go similarity index 84% rename from main_test.go rename to test.go index daa47ca..9641d70 100644 --- a/main_test.go +++ b/test.go @@ -2,19 +2,21 @@ package main import ( "github.com/layeh/gumble/gumble" - "os" - "testing" ) -func createClient(uname string) *gumble.Client { - return gumble.NewClient(&gumble.Config{ - Username: uname, - Password: os.Getenv("MUMBLE_PASSWORD"), - Address: os.Getenv("MUMBLE_IP") + ":" + os.Getenv("MUMBLE_PORT")}) +func Test(password, ip, port string) { + } -func TestYoutubeSong(t *testing.T) { - dummyClient := createClient("dummy") +func createClient(uname, password, ip, port string) *gumble.Client { + return gumble.NewClient(&gumble.Config{ + Username: uname, + Password: password, + Address: ip + ":" + port}) +} + +func testYoutubeSong(password, ip, port string) { + dummyClient := createClient("dummy", password, ip, port) dummyClient.Connect() dummyUser := dj.client.Users.Find("dummy")