mirror of https://github.com/fmartingr/bazaar.git
test: added gtmstore test
This commit is contained in:
parent
c71c9b0517
commit
cf94a590b7
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,6 @@ package gtmstore
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -42,7 +41,6 @@ func (s *GTMStoreShop) Get(u *url.URL) (*models.Product, error) {
|
|||
s.Find(".woocommerce-product-gallery__wrapper div").Each(func(i int, s *goquery.Selection) {
|
||||
imageURL, exists := s.Find("a").Attr("href")
|
||||
if exists {
|
||||
log.Println(imageURL)
|
||||
imageURLs = append(imageURLs, imageURL)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package gtmstore_test
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/fmartingr/bazaar/pkg/clients"
|
||||
"github.com/fmartingr/bazaar/pkg/models"
|
||||
"github.com/fmartingr/bazaar/pkg/shop/gtmstore"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGtmStore_Ok(t *testing.T) {
|
||||
shop := gtmstore.NewGTMStoreShopFactory()(models.NewShopOptions(clients.NewMockClient()))
|
||||
|
||||
testUrl, _ := url.Parse("https://www.gtm-store.com/test/")
|
||||
|
||||
product, err := shop.Get(testUrl)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
t.Log(product)
|
||||
|
||||
assert.NotEmpty(t, product.Description)
|
||||
assert.Equal(t, "Metroid: Misión Omega", product.Name)
|
||||
assert.Equal(t, "https://www.gtm-store.com/wp-content/uploads/2022/07/GTM-Metroid-4.jpeg", product.ImageURL)
|
||||
assert.Equal(t, 8.99, product.Price)
|
||||
assert.Equal(t, "8,99", product.PriceText)
|
||||
assert.Equal(t, testUrl.String(), product.URL)
|
||||
}
|
Loading…
Reference in New Issue