{"modulePath":"github.com/muonsoft/api-testing","version":"v0.12.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package assertxml\n\nPackage assertxml provides methods for testing XML values. Selecting XML values provided by XML Path Syntax.\n\nExample usage\n\n\timport (\n\t    \"net/http\"\n\t    \"net/http/httptest\"\n\t    \"testing\"\n\t    \"github.com/muonsoft/api-testing/assertxml\"\n\t )\n\n\t func TestYourAPI(t testing.TB) {\n\t    recorder := httptest.NewRecorder()\n\t    handler := createHTTPHandler()\n\n\t    request, _ := http.NewRequest(\"GET\", \"/content\", nil)\n\t    handler.ServeHTTP(recorder, request)\n\n\t    assertxml.Has(t, recorder.Body.Bytes(), func(xml *AssertXML) {\n\t        // common assertions\n\t        xml.Node(\"/root/stringNode\").Exists()\n\t        xml.Node(\"/root/notExistingNode\").DoesNotExist()\n\n\t        // string assertions\n\t        xml.Node(\"/root/stringNode\").EqualToTheString(\"stringValue\")\n\t    })\n\t }\n\n## Functions\n\n```go\nfunc FileHas(t TestingT, filename string, xmlAssert XMLAssertFunc)\n```\nFileHas loads XML from file and runs user callback for testing its nodes.\n\n```go\nfunc Has(t TestingT, data []byte, xmlAssert XMLAssertFunc)\n```\nHas loads XML from byte slice and runs user callback for testing its nodes.\n\n## Types\n\n```go\ntype AssertNode struct {\n\t// contains filtered or unexported fields\n}\n```\nAssertNode - structure for asserting XML node.\n\n```go\nfunc (node *AssertNode) DoesNotExist(msgAndArgs ...interface{})\n```\nDoesNotExist asserts that the XML node does not exist.\n\n```go\nfunc (node *AssertNode) EqualToTheString(expectedValue string, msgAndArgs ...interface{})\n```\nEqualToTheString asserts that the XML node has a string value equals to the given value.\n\n```go\nfunc (node *AssertNode) Exists(msgAndArgs ...interface{})\n```\nExists asserts that the XML node exists.\n\n```go\ntype AssertXML struct {\n\t// contains filtered or unexported fields\n}\n```\nAssertXML - main structure that holds parsed XML.\n\n```go\nfunc (x *AssertXML) Node(path string) *AssertNode\n```\nNode searches for XML node by XML Path Syntax. Returns struct for asserting the node values.\n\n```go\nfunc (x *AssertXML) Nodef(format string, a ...interface{}) *AssertNode\n```\nNodef searches for XML node by XML Path Syntax. Returns struct for asserting the node values. It calculates path by applying fmt.Sprintf function.\n\n```go\ntype TestingT interface {\n\tHelper()\n\tError(args ...interface{})\n\tErrorf(format string, args ...interface{})\n\tLog(args ...interface{})\n\tFailed() bool\n}\n```\nTestingT is an interface wrapper around \\*testing.T.\n\n```go\ntype XMLAssertFunc func(xml *AssertXML)\n```\nXMLAssertFunc - callback function used for asserting XML nodes.\n\n","path":"github.com/muonsoft/api-testing/assertxml","name":"assertxml","synopsis":"Package assertxml provides methods for testing XML values.","isRedistributable":true}
