File: commandlist_test.go

package info (click to toggle)
golang-github-fhs-gompd 2.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208 kB
  • sloc: makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2013 The GoMPD Authors. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.

package mpd

import (
	"testing"
)

func TestCurrentSongPromise(t *testing.T) {
	cli := localDial(t)
	defer teardown(cli, t)

	cmdl := cli.BeginCommandList()

	pa := cmdl.CurrentSong()

	if err := cmdl.End(); err != nil {
		t.Errorf("CommandList.End failed: %s", err)
	}

	if _, err := pa.Value(); err != nil {
		t.Errorf("Promise did not compute: %s", err)
	}

}

func TestCommandList(t *testing.T) {
	cli := localDial(t)
	defer teardown(cli, t)

	// Normal command list:
	cmdl := cli.BeginCommandList()

	cmdl.Next()
	cmdl.Next()
	cmdl.Next()

	if err := cmdl.End(); err != nil {
		t.Errorf("CommandList.End failed: %s", err)
	}

	// Test empty command list:
	cmdl2 := cli.BeginCommandList()
	if err := cmdl2.End(); err != nil {
		t.Errorf("CommandList.End failed: %s", err)
	}

	// Reuse old comandlist (should work):
	cmdl.Previous()
	cmdl.Previous()
	cmdl.Previous()
	if err := cmdl.End(); err != nil {
		t.Errorf("CommandList.End failed: %s", err)
	}

}