Debian Codegraph @

mpd/commandlist_test.go

raw symbols SCIP
1 // Copyright 2013 The GoMPD Authors. All rights reserved.
2 // Use of this source code is governed by the MIT
3 // license that can be found in the LICENSE file.
4
5 package mpd
6
7 import (
8 "testing"
9 )
10
11 func TestCurrentSongPromise(t *testing.T) {
12 cli := localDial(t)
13 defer teardown(cli, t)
14
15 cmdl := cli.BeginCommandList()
16
17 pa := cmdl.CurrentSong()
18
19 if err := cmdl.End(); err != nil {
20 t.Errorf("CommandList.End failed: %s", err)
21 }
22
23 if _, err := pa.Value(); err != nil {
24 t.Errorf("Promise did not compute: %s", err)
25 }
26
27 }
28
29 func TestCommandList(t *testing.T) {
30 cli := localDial(t)
31 defer teardown(cli, t)
32
33 // Normal command list:
34 cmdl := cli.BeginCommandList()
35
36 cmdl.Next()
37 cmdl.Next()
38 cmdl.Next()
39
40 if err := cmdl.End(); err != nil {
41 t.Errorf("CommandList.End failed: %s", err)
42 }
43
44 // Test empty command list:
45 cmdl2 := cli.BeginCommandList()
46 if err := cmdl2.End(); err != nil {
47 t.Errorf("CommandList.End failed: %s", err)
48 }
49
50 // Reuse old comandlist (should work):
51 cmdl.Previous()
52 cmdl.Previous()
53 cmdl.Previous()
54 if err := cmdl.End(); err != nil {
55 t.Errorf("CommandList.End failed: %s", err)
56 }
57
58 }