-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
42 lines (35 loc) · 1.09 KB
/
app.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
package app
import (
"encoding/json"
"os"
"github.com/Moon1706/ginkgo2allure/pkg/convert"
fmngr "github.com/Moon1706/ginkgo2allure/pkg/convert/file_manager"
"github.com/Moon1706/ginkgo2allure/pkg/convert/parser"
"github.com/onsi/ginkgo/v2/types"
"go.uber.org/zap"
)
func StartConvertion(ginkgoReportFile, allureReportsFolder string, config parser.Config, logger *zap.Logger) {
sugar := logger.Sugar()
file, err := os.ReadFile(ginkgoReportFile)
if err != nil {
sugar.Fatal("Error reading file `%s`", ginkgoReportFile)
}
var ginkgoReport []types.Report
err = json.Unmarshal(file, &ginkgoReport)
if err != nil {
sugar.Fatal("Error unmarshaling file `%s`", ginkgoReportFile)
}
allureReports, err := convert.GinkgoToAllureReport(ginkgoReport, parser.NewDefaultParser,
config)
if err != nil {
sugar.Fatal("Error converting report `%s`", ginkgoReportFile)
}
fileManager := fmngr.NewFileManager(allureReportsFolder)
errs := convert.PrintAllureReports(allureReports, fileManager)
for _, err := range errs {
sugar.Error(err)
}
if len(errs) != 0 {
sugar.Fatal("Saving errors")
}
}