-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler_test.go
More file actions
39 lines (33 loc) · 1.12 KB
/
handler_test.go
File metadata and controls
39 lines (33 loc) · 1.12 KB
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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package main
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestExtractService(t *testing.T) {
Convey("Given a service full name of a service", t, func() {
serviceFullName := "config.redis"
Convey("gets its name", func() {
service := extractService(serviceFullName)
So(service, ShouldEqual, "redis")
})
})
Convey("Given an invalid full name of a service", t, func() {
serviceFullName := "foo"
Convey("can't get the name, get the entire string", func() {
service := extractService(serviceFullName)
So(service, ShouldEqual, "foo")
})
})
}
func TestGetServiceConfig(t *testing.T) {
Convey("Given a valid configuration fixture", t, func() {
configPath := "./test/fixtures/config.json"
Convey("Load a service configuration correctly", func() {
service := getServiceConfig("monitor", configPath)
So(string(service), ShouldEqual, `{"host":"127.0.0.1","port":"22000"}`)
})
})
}