about summary refs log tree commit diff
path: root/tools/mpd-stats/internal/scrobbler/record_test.go
blob: 3bf8554943730cfe91b065bb44498d0ae555d549 (plain) (blame)
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
package scrobbler

import (
	"testing"

	"github.com/fhs/gompd/v2/mpd"
)

func TestNewRecord(t *testing.T) {
	song := mpd.Attrs{
		"Artist":   "Nine Inch Nails",
		"Album":    "The Downward Spiral",
		"Title":    "Reptile",
		"duration": "411.00",
	}

	record, err := NewRecord(song)
	if err != nil {
		t.Errorf("NewRecord returned an error: %s", err)
	}
	if record == nil {
		t.Errorf("NewRecord returned nil record")
	}
}

func TestRecordEqualAttrs(t *testing.T) {
	s1 := mpd.Attrs{
		"Artist":   "Nine Inch Nails",
		"Album":    "The Downward Spiral",
		"Title":    "Reptile",
		"duration": "411.00",
	}

	s2 := mpd.Attrs{
		"Artist":   "Nine Inch Nails",
		"Album":    "The Downward Spiral",
		"Title":    "Closer",
		"duration": "373.00",
	}

	r, err := NewRecord(s1)
	if err != nil {
		t.Errorf("NewRecord returned an error: %s", err)
	}

	if !r.EqualAttrs(s1) {
		t.Errorf("EqualAttrs expected true got false")
	}

	if r.EqualAttrs(s2) {
		t.Errorf("EqualAttrs expected false got true")
	}
}