-
Notifications
You must be signed in to change notification settings - Fork 0
/
tobpmn_test.go
49 lines (41 loc) · 983 Bytes
/
tobpmn_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
package gobpmn_builder_test
import (
"encoding/xml"
"fmt"
"os"
"testing"
"github.com/deemount/gobpmnModels/pkg/core"
)
func TestToBPMN(t *testing.T) {
t.Run("TestToBPMN()",
func(t *testing.T) {
var err error
// create a new repository
repo := core.NewDefinitions()
repo.SetDefaultAttributes()
repo.SetID("definitions", "1234")
repo.SetMainElements(1)
// marshal xml to byte slice
b, err := xml.MarshalIndent(&repo, " ", " ")
if err != nil {
t.Errorf("expected nil, got %v", err)
}
// create .bpmn file
f, err := os.Create(DefaultFiletestPath + "/test.bpmn")
if err != nil {
t.Errorf("expected nil, got %v", err)
}
defer f.Close()
// add xml header
w := []byte(fmt.Sprintf("%v", xml.Header+string(b)))
// write bytes to file
_, err = f.Write(w)
if err != nil {
t.Errorf("expected nil, got %v", err)
}
err = f.Sync()
if err != nil {
t.Errorf("expected nil, got %v", err)
}
})
}