-
Notifications
You must be signed in to change notification settings - Fork 15
/
quirks_test.go
56 lines (46 loc) · 1.28 KB
/
quirks_test.go
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
/* ipp-usb - HTTP reverse proxy, backed by IPP-over-USB connection to device
*
* Copyright (C) 2020 and up by Alexander Pevzner ([email protected])
* See LICENSE for license terms and conditions
*
* Tests for device-specific quirks
*/
package main
import (
"testing"
)
// Test quirls loading and lookup
func TestQuirksSetLoadAndLookup(t *testing.T) {
const path = "testdata/quirks"
const badPath = path + "-not-exist"
// Try non-existent directory
_, err := LoadQuirksSet(badPath)
if err != nil {
t.Fatalf("LoadQuirksSet(%q): %s", badPath, err)
}
// Try test data
qset, err := LoadQuirksSet(path)
if err != nil {
t.Fatalf("LoadQuirksSet(%q): %s", path, err)
}
// Test default quirks
quirks := qset.ByModelName("unknown device")
if quirks == nil {
t.Fatalf("default quirls: missed")
}
if len(quirks) != 1 {
t.Fatalf("default quirls: expected 1, got %d", len(quirks))
}
// Test quirks for some known device
device := "HP LaserJet MFP M28-M31"
quirks = qset.ByModelName(device)
if quirks == nil {
t.Fatalf("%q quirls: missed", device)
}
if len(quirks) != 1 { // default overridden by this device
t.Fatalf("%q quirls: expected 1, got %d", device, len(quirks))
}
if quirks[0].Model != device {
t.Fatalf("%q quirls: wrong ordering of returned quirks", device)
}
}