This repository has been archived on 2019-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mumbledj/test.go

51 lines
1.8 KiB
Go
Raw Normal View History

2015-08-10 01:41:26 +02:00
package main
2015-08-10 01:42:41 +02:00
import (
2015-08-10 02:22:32 +02:00
"fmt"
2015-08-10 01:42:41 +02:00
"github.com/layeh/gumble/gumble"
2015-08-10 20:29:58 +02:00
"time"
2015-08-10 01:42:41 +02:00
)
2015-08-10 01:41:26 +02:00
2015-08-10 02:19:27 +02:00
func Test(password, ip, port string) {
2015-08-10 20:29:58 +02:00
testYoutubeSong(password, ip, port)
2015-08-10 02:19:27 +02:00
}
func createClient(uname, password, ip, port string) *gumble.Client {
2015-08-10 01:41:26 +02:00
return gumble.NewClient(&gumble.Config{
Username: uname,
2015-08-10 02:19:27 +02:00
Password: password,
Address: ip + ":" + port})
2015-08-10 01:41:26 +02:00
}
2015-08-10 02:19:27 +02:00
func testYoutubeSong(password, ip, port string) {
dummyClient := createClient("dummy", password, ip, port)
2015-08-10 01:57:08 +02:00
dummyClient.Connect()
2015-08-10 01:59:06 +02:00
dummyUser := dj.client.Users.Find("dummy")
2015-08-10 01:41:26 +02:00
// Don't judge, I used the (autogenerated) Top Tracks for United Kingdom playlist
songs := map[string]string{
"http://www.youtube.com/watch?v=QcIy9NiNbmo": "Taylor Swift - Bad Blood ft. Kendrick Lamar",
"https://www.youtube.com/watch?v=vjW8wmF5VWc": "Silentó - Watch Me (Whip/Nae Nae) (Official)",
"http://youtu.be/nsDwItoNlLc": "Tinie Tempah ft. Jess Glynne - Not Letting Go (Official Video)",
"https://youtu.be/hXTAn4ELEwM": "Years & Years - Shine",
"http://youtube.com/watch?v=RgKAFK5djSk": "Wiz Khalifa - See You Again ft. Charlie Puth [Official Video] Furious 7 Soundtrack",
"https://youtube.com/watch?v=qWWSM3wCiKY": "Calvin Harris & Disciples - How Deep Is Your Love (Audio)",
"http://www.youtube.com/v/yzTuBuRdAyA": "The Weeknd - The Hills",
"https://www.youtube.com/v/cNw8A5pwbVI": "Pia Mia - Do It Again ft. Chris Brown, Tyga",
}
for url, title := range songs {
2015-08-10 01:57:08 +02:00
err := add(dummyUser, url)
2015-08-10 01:41:26 +02:00
if err != nil {
2015-08-10 02:22:32 +02:00
fmt.Printf("For: %s; Expected: %s; Got: %s", url, title, err.Error())
2015-08-10 01:41:26 +02:00
} else if dj.queue.CurrentSong().Title() != title {
2015-08-10 02:22:32 +02:00
fmt.Printf("For: %s; Expected: %s; Got: %s", url, title, dj.queue.CurrentSong().Title())
2015-08-10 01:41:26 +02:00
}
2015-08-10 20:29:58 +02:00
sleep(time.Second * 5)
2015-08-10 01:57:08 +02:00
skip(dummyUser, false, false)
2015-08-10 01:41:26 +02:00
}
2015-08-10 01:57:08 +02:00
dummyClient.Disconnect()
2015-08-10 01:41:26 +02:00
}