-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiendainglesa_test.go
57 lines (47 loc) · 1.57 KB
/
tiendainglesa_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
57
package scraping
import "testing"
func TestTiendaInglesaUrl(t *testing.T) {
url := "http://www.tinglesa.com.uy/producto.php?idarticulo=86"
isDevoto := TiendaInglesaUrl(url)
if !isDevoto {
t.Errorf("TiendaInglesaUrl(%s) = %t, want %t", url, isDevoto, true)
}
url = "http://tinglesa.com.uy/producto.php?idarticulo=86"
isDevoto = TiendaInglesaUrl(url)
if !isDevoto {
t.Errorf("TiendaInglesaUrl(%s) = %t, want %t", url, isDevoto, true)
}
url = "www.tinglesa.com.uy/producto.php?idarticulo=86"
isDevoto = TiendaInglesaUrl(url)
if isDevoto {
t.Errorf("TiendaInglesaUrl(%s) = %t, want %t", url, isDevoto, false)
}
url = "http://www.devoto.com.uy/producto.php?idarticulo=86"
isDevoto = TiendaInglesaUrl(url)
if isDevoto {
t.Errorf("TiendaInglesaUrl(%s) = %t, want %t", url, isDevoto, false)
}
}
func TestTiendaInglesaFetchProduct(t *testing.T) {
url := "http://www.tinglesa.com.uy/producto.php?idarticulo=86"
productData, err := TiendaInglesa(url)
if err != nil {
t.Errorf("TiendaInglesa(%s) returned error %v", url, err)
}
exceptedName := "Arroz Saman Parboiled 1kg"
if productData.Name != exceptedName {
t.Errorf("TiendaInglesa(%s).Name = %s, want %s", url, productData.Name, exceptedName)
}
var expectedPrice float64
expectedPrice = 40.00
if productData.Price != expectedPrice {
t.Errorf("TiendaInglesa(%s).Price = %v, want %v", url, productData.Price, expectedPrice)
}
}
func TestTiendaInglesaFetchProductError(t *testing.T) {
url := "http://tinglesa.com.uy/"
_, err := TiendaInglesa(url)
if err == nil {
t.Errorf("TiendaInglesa(%s) didnt error", url)
}
}