Skip to content

Commit f1fb13b

Browse files
committed
added some tests
1 parent 6f9679b commit f1fb13b

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

Gopkg.lock

+28-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131

3232
[[constraint]]
3333
branch = "master"
34-
name = "github.com/globalsign/mgo"
34+
name = "github.com/globalsign/mgo"

pkg/util/main_test.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package util
2+
3+
import (
4+
"github.com/stretchr/testify/assert"
5+
"testing"
6+
)
7+
8+
func TestStringInSlice(t *testing.T) {
9+
var actual bool
10+
11+
actual = StringInSlice("plane", []string{"bus", "car", "bike"})
12+
assert.Equal(t, false, actual)
13+
14+
actual = StringInSlice("bus", []string{"bus", "car", "bike"})
15+
assert.Equal(t, true, actual)
16+
}
17+
18+
func TestJsonEncode(t *testing.T) {
19+
var actual string
20+
21+
actual = JsonEncode([]string{"bus", "car", "bike"})
22+
assert.Equal(t, `["bus","car","bike"]`, actual)
23+
24+
actual = JsonEncode(map[string]int{"bus": 200, "car": 300, "bike": 400})
25+
assert.Equal(t, `{"bike":400,"bus":200,"car":300}`, actual)
26+
}
27+
28+

0 commit comments

Comments
 (0)