forked from hooklift/gowsdl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gowsdl_test.go
79 lines (67 loc) · 1.69 KB
/
gowsdl_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package gowsdl
import (
"bytes"
"go/format"
"path/filepath"
"strings"
"testing"
)
func TestElementGenerationDoesntCommentOutStructProperty(t *testing.T) {
g := GoWSDL{
file: "fixtures/test.wsdl",
pkg: "myservice",
makePublicFn: makePublic,
}
resp, err := g.Start()
if err != nil {
t.Error(err)
}
if strings.Contains(string(resp["types"]), "// this is a comment GetInfoResult string `xml:\"GetInfoResult,omitempty\"`") {
t.Error("Type comment should not comment out struct type property")
t.Error(string(resp["types"]))
}
}
func TestVboxGeneratesWithoutSyntaxErrors(t *testing.T) {
files, err := filepath.Glob("fixtures/*.wsdl")
if err != nil {
t.Error(err)
}
for _, file := range files {
g := GoWSDL{
file: file,
pkg: "myservice",
makePublicFn: makePublic,
}
resp, err := g.Start()
if err != nil {
continue
//t.Error(err)
}
data := new(bytes.Buffer)
data.Write(resp["header"])
data.Write(resp["types"])
data.Write(resp["operations"])
data.Write(resp["soap"])
_, err = format.Source(data.Bytes())
if err != nil {
t.Error(err)
}
}
}
func TestSOAPHeaderGeneratesWithoutErrors(t *testing.T) {
g := GoWSDL{
file: "fixtures/ferry.wsdl",
pkg: "myservice",
makePublicFn: makePublic,
}
resp, err := g.Start()
if err != nil {
t.Error(err)
}
if !strings.Contains(string(resp["operations"]), "SetHeader") {
t.Error("SetHeader method should be generated in the service operation")
}
}