-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread_test.go
More file actions
33 lines (29 loc) · 843 Bytes
/
thread_test.go
File metadata and controls
33 lines (29 loc) · 843 Bytes
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
package fourchan
import (
"testing"
)
func TestExtractBoardAndThreadId(t *testing.T) {
tests := []struct {
url, board, id string
}{
{"https://boards.4chan.org/wsg/thread/921167/cats", "wsg", "921167"},
{"https://boards.4chan.org/wsg/thread/921167", "wsg", "921167"},
{"https://boards.4chan.org/g/thread/51971506", "g", "51971506"},
{"https://boards.4chan.org/g/thread/51971506#p51971506", "g", "51971506"},
}
for _, test := range tests {
board, id, err := extractBoardAndThreadId(test.url)
if err != nil {
t.Fatal(err)
}
if board != test.board || id != test.id {
t.Fatalf("%s: %s/%s != %s/%s", test.url, board, id, test.board, test.id)
}
}
}
func TestExtractBoardAndThreadIdFails(t *testing.T) {
_, _, err := extractBoardAndThreadId("https://www.google.com")
if err == nil {
t.Fatal("err was nil")
}
}