-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathset_test.go
More file actions
50 lines (41 loc) · 984 Bytes
/
set_test.go
File metadata and controls
50 lines (41 loc) · 984 Bytes
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
49
50
package jsonconsul
import (
"fmt"
"testing"
)
func ExampleJsonSet_RunBadJson() {
ji := &JsonSet{}
ji.ParseFlags([]string{"blah/blah", "\"a"})
err := ji.Run()
fmt.Println(err)
// Output:
// Can't set the key blah/blah invalid value: "a
// If it is a string please wrap the value with quotes. Ex. \"value\"
}
func ExampleJsonSet_RunBadExpectedType() {
ji := &JsonSet{}
ji.ParseFlags([]string{"blah/blah", "true"})
ji.setExpectedType("int")
err := ji.Run()
fmt.Println(err)
// Output:
// Invalid type. Value is a bool. Expected number
}
func TestJsonSet_RunGoodExpectedTypeBool(t *testing.T) {
ji := &JsonSet{}
ji.ParseFlags([]string{"blah/blah", "true"})
ji.setExpectedType("bool")
err := ji.Run()
if err != nil {
t.Error(err)
}
}
func TestJsonSet_RunGoodExpectedTypeString(t *testing.T) {
ji := &JsonSet{}
ji.ParseFlags([]string{"blah/str", "\"this is a string\""})
ji.setExpectedType("string")
err := ji.Run()
if err != nil {
t.Error(err)
}
}