-
Notifications
You must be signed in to change notification settings - Fork 0
/
product_repository_int_test.go
46 lines (38 loc) · 1.46 KB
/
product_repository_int_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
//go:build integration || ci
package docweaver_test
import (
"fmt"
"github.com/reliqarts/go-docweaver"
"github.com/stretchr/testify/assert"
"testing"
)
var repo = docweaver.GetRepository(docsDir)
func TestProductRepository_FindProduct(t *testing.T) {
expectedName := "Product One"
product, err := repo.FindProduct(testProductKey)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, expectedName, product.Name)
assert.Equal(t, "Simple test product.", product.Description)
assert.Contains(t, product.ImageUrl, fmt.Sprintf("%s/%s/main/", docweaver.GetAssetsRoutePrefix(), testProductKey))
assert.Contains(t, fmt.Sprintf("%s", product.Versions), "1.0")
assert.NotContains(t, fmt.Sprintf("%s", product.Versions), "2.0-temp")
}
func TestProductRepository_GetPage(t *testing.T) {
versions := []string{"main", "1.0"}
for _, version := range versions {
t.Run(version, func(t *testing.T) {
page, err := repo.GetPage(testProductKey, version, "installation")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "Product 1", page.Title)
assert.Equal(t, version, page.Version)
assert.Contains(t, page.Content, fmt.Sprintf("/docs/%s/%s/", testProductKey, version))
assert.Contains(t, page.Content, "href=\"http://iamreliq.com\"")
assert.Contains(t, page.Index.Content, fmt.Sprintf("href=\"/docs/%s/%s/support\"", testProductKey, version))
assert.Contains(t, page.Index.Content, fmt.Sprintf("href=\"/docs/%s/%s/installation\"", testProductKey, version))
})
}
}