-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathe2e_test.go
47 lines (39 loc) · 1.12 KB
/
e2e_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
package main
import (
"fmt"
"github.com/konveyor/windup-shim/pkg/conversion"
"github.com/konveyor/windup-shim/pkg/windup"
"log"
"os"
"path/filepath"
"testing"
)
func Test_convertRule(t *testing.T) {
rulesets := []windup.Ruleset{}
ruleTests := []windup.Ruletest{}
err := filepath.WalkDir("./data", walkXML("./data/test_ruleset.xml", &rulesets, &ruleTests, false))
if err != nil {
fmt.Println(err)
}
_, err = conversion.ConvertWindupRulesetsToAnalyzer(rulesets, "./data/test_ruleset.xml", "./test-rule-output", true, false)
if err != nil {
log.Fatal(err)
}
defer func() {
err := os.RemoveAll("./test-rule-output")
if err != nil {
t.Fatalf("Failed to remove output directory %v", err)
}
}()
expected, err := os.ReadFile("./data/test_rule.yaml")
if err != nil {
t.Fatalf("Failed to read the original yaml: %v", err)
}
output, err := os.ReadFile("./test-rule-output/data/01-test_rule.yaml")
if err != nil {
t.Fatalf("Failed to read the output yaml: %v", err)
}
if string(expected) != string(output) {
t.Fatalf("YAML files do not match\nExpected: %v\nGot: %v", string(expected), string(output))
}
}