-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsuite_test.go
48 lines (39 loc) · 932 Bytes
/
suite_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
43
44
45
46
47
48
package eureka_test
import (
"encoding/xml"
"os"
"path/filepath"
"regexp"
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/st3v/go-eureka"
)
func TestEureka(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "go-eureka")
}
func removeIdendation(data []byte) []byte {
r := regexp.MustCompile("\\n\\s*")
return r.ReplaceAll(data, []byte{})
}
func instanceFixture() (*eureka.Instance, error) {
fixture, err := os.Open(filepath.Join("fixtures", "instance.xml"))
if err != nil {
return nil, err
}
defer fixture.Close()
instance := new(eureka.Instance)
return instance, xml.NewDecoder(fixture).Decode(&instance)
}
func appFixture() (*eureka.App, error) {
instance, err := instanceFixture()
if err != nil {
return nil, err
}
return &eureka.App{
XMLName: xml.Name{Local: "application"},
Name: instance.AppName,
Instances: []*eureka.Instance{instance},
}, nil
}