(t *testing.T)
| 69 | } |
| 70 | |
| 71 | func TestXMLGetNodeValue(t *testing.T) { |
| 72 | if err := Init(nil); err != nil { |
| 73 | t.Fatal(err) |
| 74 | } |
| 75 | |
| 76 | tests := []struct { |
| 77 | name string |
| 78 | xmlString string |
| 79 | path string |
| 80 | expectResult string |
| 81 | }{ |
| 82 | { |
| 83 | name: "XMLGetNodeValue", |
| 84 | xmlString: `<root><child>foobar</child></root>`, |
| 85 | path: "/root/child", |
| 86 | expectResult: "foobar", |
| 87 | }, |
| 88 | { |
| 89 | name: "Non existing path for XMLGetNodeValue", |
| 90 | xmlString: `<root><child>foobar</child></root>`, |
| 91 | path: "/foo/bar", |
| 92 | expectResult: "", |
| 93 | }, |
| 94 | { |
| 95 | name: "Invalid XML for XMLGetNodeValue", |
| 96 | xmlString: `<root><`, |
| 97 | path: "/foo/bar", |
| 98 | expectResult: "", |
| 99 | }, |
| 100 | { |
| 101 | name: "Invalid path for XMLGetNodeValue", |
| 102 | xmlString: `<root><child>foobar</child></root>`, |
| 103 | path: "/foo/bar[@", |
| 104 | expectResult: "", |
| 105 | }, |
| 106 | } |
| 107 | |
| 108 | for _, test := range tests { |
| 109 | result, _ := XMLGetNodeValue(test.xmlString, test.path) |
| 110 | |
| 111 | isOk := assert.Equal(t, test.expectResult, result) |
| 112 | if !isOk { |
| 113 | t.Fatalf("test '%s' failed", test.name) |
| 114 | } |
| 115 | |
| 116 | log.Printf("test '%s' : OK", test.name) |
| 117 | } |
| 118 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…