-
Notifications
You must be signed in to change notification settings - Fork 0
/
hana_test.go
42 lines (35 loc) · 882 Bytes
/
hana_test.go
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
38
39
40
41
42
package main
import (
"encoding/xml"
"io/ioutil"
"os"
"testing"
)
func TestHanaPrimaryTrue(t *testing.T) {
xmlFile, err := os.Open("test/crm_mon.xml")
if err != nil {
t.Error(err)
}
defer xmlFile.Close()
byteValue, _ := ioutil.ReadAll(xmlFile)
var cMon CrmMon
xml.Unmarshal(byteValue, &cMon)
hanaRes := lookUpHanaNodePrimary(&cMon, "hana01")
if hanaRes != "msl_SAPHana_PRD_HDB00" {
t.Logf("GOT: %s, EXPECTED: msl_SAPHana_PRD_HDB00", hanaRes)
t.Errorf("HanaNodePrimary should have returned the resource id")
}
}
func TestHanaPrimaryFalse(t *testing.T) {
xmlFile, err := os.Open("test/crm_mon.xml")
if err != nil {
t.Error(err)
}
defer xmlFile.Close()
byteValue, _ := ioutil.ReadAll(xmlFile)
var cMon CrmMon
xml.Unmarshal(byteValue, &cMon)
if lookUpHanaNodePrimary(&cMon, "hana02") != "" {
t.Errorf("we should not have found primary node")
}
}