-
Notifications
You must be signed in to change notification settings - Fork 34
/
handlersettings_test.go
47 lines (40 loc) · 1.2 KB
/
handlersettings_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
package main
import "testing"
import "github.com/stretchr/testify/require"
func Test_handlerSettingsValidate(t *testing.T) {
// commandToExecute not specified
require.Equal(t, errCmdMissing, handlerSettings{
publicSettings{},
protectedSettings{},
}.validate())
// commandToExecute specified twice
require.Equal(t, errCmdTooMany, handlerSettings{
publicSettings{CommandToExecute: "foo"},
protectedSettings{CommandToExecute: "foo"},
}.validate())
// storageAccount name specified; but not key
require.Equal(t, errStoragePartialCredentials, handlerSettings{
protectedSettings: protectedSettings{
CommandToExecute: "date",
StorageAccountName: "foo",
StorageAccountKey: ""},
}.validate())
// storageAccount key specified; but not name
require.Equal(t, errStoragePartialCredentials, handlerSettings{
protectedSettings: protectedSettings{
CommandToExecute: "date",
StorageAccountName: "",
StorageAccountKey: "foo"},
}.validate())
}
func Test_toJSON_empty(t *testing.T) {
s, err := toJSON(nil)
require.Nil(t, err)
require.Equal(t, "{}", s)
}
func Test_toJSON(t *testing.T) {
s, err := toJSON(map[string]interface{}{
"a": 3})
require.Nil(t, err)
require.Equal(t, `{"a":3}`, s)
}