64 lines
2 KiB
Go
64 lines
2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/layeh/gumble/gumble"
|
|
"time"
|
|
)
|
|
|
|
type TestSettings struct {
|
|
password string
|
|
ip string
|
|
port string
|
|
}
|
|
|
|
var test TestSettings
|
|
|
|
func Test(password, ip, port string) {
|
|
test = TestSettings{
|
|
password: password,
|
|
ip: ip,
|
|
port: port,
|
|
}
|
|
}
|
|
|
|
func (t TestSettings) createClient(uname string) *gumble.Client {
|
|
return gumble.NewClient(&gumble.Config{
|
|
Username: uname,
|
|
Password: t.password,
|
|
Address: t.ip + ":" + t.port})
|
|
}
|
|
|
|
func (t TestSettings) testYoutubeSong() {
|
|
dummyClient := t.createClient("dummy")
|
|
dummyClient.Connect()
|
|
time.Sleep(time.Second * 5) // Give dummy time to connect
|
|
dummyUser := dj.client.Users.Find("dummy") // May be nil
|
|
|
|
// 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 {
|
|
err := add(dummyUser, url)
|
|
if err != nil {
|
|
fmt.Printf("For: %s; Expected: %s; Got: %s", url, title, err.Error())
|
|
} else if dj.queue.CurrentSong().Title() != title {
|
|
fmt.Printf("For: %s; Expected: %s; Got: %s", url, title, dj.queue.CurrentSong().Title())
|
|
}
|
|
|
|
time.Sleep(time.Second * 5)
|
|
skip(dummyUser, false, false)
|
|
}
|
|
|
|
dummyClient.Disconnect()
|
|
}
|