Skip to content

Commit

Permalink
Add more tests for test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
AjithPanneerselvam committed Jul 6, 2020
1 parent 696d09f commit fefe68c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
5 changes: 3 additions & 2 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ func (e FaultError) Error() string {
}

// IsFault returns whether the given error is a fault error or not.
// NOTE: IsFault will return false when the error could not be typecasted to FaultError, because
// every fault error will have it's dynamic type as FaultError.
//
// IsFault will return false when the error could not be typecasted to FaultError, because
// every fault error should have it's dynamic type as FaultError.
func IsFault(err error) bool {
if _, ok := err.(FaultError); !ok {
return false
Expand Down
1 change: 1 addition & 0 deletions wsdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func (wsdl *wsdlDefinitions) GetSoapActionFromWsdlOperation(operation string) st
}

// Fault response
// Fault implements Stringer interface
type Fault struct {
Code string `xml:"faultcode"`
Description string `xml:"faultstring"`
Expand Down
26 changes: 26 additions & 0 deletions wsdl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"runtime"
"strings"
"testing"

"gotest.tools/assert"
)

func Test_getWsdlBody(t *testing.T) {
Expand Down Expand Up @@ -66,3 +68,27 @@ func Test_getWsdlBody(t *testing.T) {
})
}
}

func TestFaultString(t *testing.T) {
var testCases = []struct {
description string
fault *Fault
expectedFaultStr string
}{
{
description: "success case: fault string",
fault: &Fault{
Code: "soap:SERVER",
Description: "soap exception",
},
expectedFaultStr: "[soap:SERVER]: soap exception",
},
}

for _, testCase := range testCases {
t.Logf("running %v testCase", testCase.description)

faultStr := testCase.fault.String()
assert.Equal(t, testCase.expectedFaultStr, faultStr)
}
}

0 comments on commit fefe68c

Please sign in to comment.