-
Notifications
You must be signed in to change notification settings - Fork 0
/
publisher_int_test.go
51 lines (42 loc) · 1.36 KB
/
publisher_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
47
48
49
50
51
//go:build integration || ci
package docweaver_test
import (
"fmt"
"github.com/reliqarts/go-docweaver"
"os"
"testing"
)
const (
docsDir string = "./testdata/docs"
testProductKey string = "product1"
)
func init() {
_ = os.Setenv(docweaver.EnvKeyAssetsDir, "./testdata/assets")
}
func TestPublisher_Publish(t *testing.T) {
productName := "docweaver"
productPath := docsDir + "/" + productName
publisher := docweaver.GetPublisherWithDocsDir(docsDir)
publisher.Publish(productName, "https://github.com/reliqarts/docweaver-docs.git", true)
versionsToCheck := []string{"main", "1.0", "2.0", "3.0", "4.0"}
if _, err := os.Stat(productPath); os.IsNotExist(err) {
t.Fatalf("Product directory not found for product `%s`", productName)
}
for _, v := range versionsToCheck {
t.Run(v, func(t *testing.T) {
if _, err := os.Stat(productPath + "/" + v); os.IsNotExist(err) {
t.Fatalf("Product version not found `%s`", productPath+"/"+v)
}
})
}
if err := os.RemoveAll(productPath); err != nil {
t.Fatalf("Failed to remove product path `%s`. %s", productPath, err)
}
assetsDir := docweaver.GetAssetsDir()
if assetsDir != "" {
assetsPath := fmt.Sprintf("%s%c%s", assetsDir, os.PathSeparator, productName)
if err := os.RemoveAll(assetsPath); err != nil {
t.Fatalf("Failed to remove published product assets at path: `%s`. %s", assetsPath, err)
}
}
}