blob: 56b4b40e8b8f5bdd9a029f0ee9fb918c66351551 (
plain)
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
|
// Copyright 2022 Nick White.
// Use of this source code is governed by the GPLv3
// license that can be found in the LICENSE file.
package main
import (
"testing"
)
func Test_getBookIdFromUrl(t *testing.T) {
cases := []struct {
url string
id string
}{
{"https://books.google.it/books?id=QjQepCuN8JYC", "QjQepCuN8JYC"},
{"https://www.google.it/books/edition/_/VJbr-Oe2au0C", "VJbr-Oe2au0C"},
}
for _, c := range cases {
t.Run(c.url, func(t *testing.T) {
id, err := getBookIdFromUrl(c.url)
if err != nil {
t.Fatalf("Error running test: %v", err)
}
if id != c.id {
t.Fatalf("Expected %s, got %s", c.id, id)
}
})
}
}
|