Skip to content

Commit

Permalink
Add simple test for enumeration generation
Browse files Browse the repository at this point in the history
  • Loading branch information
cursork committed Apr 25, 2017
1 parent ac1993f commit 9b29696
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions gowsdl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bytes"
"go/format"
"path/filepath"
"regexp"
"strings"
"testing"
)
Expand Down Expand Up @@ -77,3 +78,30 @@ func TestSOAPHeaderGeneratesWithoutErrors(t *testing.T) {
t.Error("SetHeader method should be generated in the service operation")
}
}

func TestEnumerationsGeneratedCorrectly(t *testing.T) {
enumStringTest := func(t *testing.T, fixtureWsdl string, varName string, typeName string, enumString string) {
g := GoWSDL{
file: "fixtures/" + fixtureWsdl,
pkg: "myservice",
makePublicFn: makePublic,
}

resp, err := g.Start()
if err != nil {
t.Error(err)
}

re := regexp.MustCompile(varName + " " + typeName + " = \"([^\"]+)\"")
matches := re.FindStringSubmatch(string(resp["types"]))

if len(matches) != 2 {
t.Errorf("No match or too many matches found for %s", varName)
} else if matches[1] != enumString {
t.Errorf("%s got '%s' but expected '%s'", varName, matches[1], enumString)
}
}
enumStringTest(t, "chromedata.wsdl", "DriveTrainFrontWheelDrive", "DriveTrain", "Front Wheel Drive")
enumStringTest(t, "vboxweb.wsdl", "SettingsVersionV1_14", "SettingsVersion", "v1_14")

}

0 comments on commit 9b29696

Please sign in to comment.