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
|
package devianter
import (
"testing"
"time"
)
// Regression: Favourites and Gallery took folderid as a variadic, which invites
// omitting it, but then indexed folderid[0] with no length check — so the call
// the signature invites most panicked with index out of range.
//
// Both reach a request before returning, and neither takes a base URL, so these
// squeeze Timeout down to make that request fail immediately. The failure is
// expected and ignored: only the absence of a panic is under test.
func TestFolderidIsOptional(t *testing.T) {
defer func(d time.Duration) { Timeout = d }(Timeout)
Timeout = time.Millisecond
s := Group{Name: "someuser"}
t.Run("Gallery", func(t *testing.T) {
if _, _, err := s.Gallery(0); err != nil {
t.Errorf("omitting folderid is not an argument error, got %v", err)
}
})
t.Run("Favourites all", func(t *testing.T) {
_, _ = s.Favourites(0, true)
})
t.Run("Favourites default listing", func(t *testing.T) {
_, _ = s.Favourites(0, false)
})
}
// Name is what every request is scoped to, so Gallery reports its absence
// rather than requesting a URL with an empty username.
func TestGalleryRequiresName(t *testing.T) {
var s Group
if _, _, err := s.Gallery(0, 0); err == nil {
t.Fatal("want an error for a Group with no Name, got nil")
}
}
|