File: namespaces_test.go

package info (click to toggle)
golang-github-masterzen-winrm 0.0~git20200615.c42b513-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 288 kB
  • sloc: makefile: 28; sh: 14
file content (37 lines) | stat: -rw-r--r-- 759 bytes parent folder | download | duplicates (2)
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
package soap

import (
	"testing"

	"github.com/masterzen/simplexml/dom"
)

func TestAddUsualNamespaces(t *testing.T) {
	doc := dom.CreateDocument()
	root := dom.CreateElement("root")
	doc.SetRoot(root)
	AddUsualNamespaces(root)

	for ns := range root.DeclaredNamespaces() {
		found := false
		for ns2 := range MostUsed {
			if ns2 == ns {
				found = true
			}
		}
		if !found {
			t.Errorf("Test failed - Namespace %v not found", ns)
		}
	}
}

func TestSetTo(t *testing.T) {
	doc := dom.CreateDocument()
	root := dom.CreateElement("root")
	doc.SetRoot(root)
	DOM_NS_SOAP_ENV.SetTo(root)

	if root.String() != `<env:root xmlns:env="http://www.w3.org/2003/05/soap-envelope"/>` {
		t.Errorf("Test failed - root has not the correct NS: %s", root.String())
	}
}