forked from liomthechef/consul-template-plugin-ssm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssm_test.go
55 lines (49 loc) · 1.33 KB
/
ssm_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
49
50
51
52
53
54
55
package main
import (
"testing"
"github.com/aws/aws-sdk-go/service/ssm"
)
func TestParseInput(t *testing.T) {
// Fail if more than one cmd line argument provided
_, err := parseInput([]string{"1", "2", "3"})
if err == nil {
t.Errorf("More than 1 arg should result in failure.")
}
// Fail if no argument provided
_, err = parseInput([]string{})
if err == nil {
t.Errorf("No args should result in failure.")
}
// should pass if 1 argument provided
_, err = parseInput([]string{"pleasepass"})
if err != nil {
t.Errorf("One argument should not result in error")
}
}
func TestGetParamValue(t *testing.T) {
paramValue := "Yay"
paramType := "String"
paramName := "Test"
input := ssm.GetParameterOutput{
// Information about a parameter.
Parameter: &ssm.Parameter{
Name: ¶mName,
Type: ¶mType,
Value: ¶mValue}}
output := getParamValue(&input)
if output != paramValue {
t.Errorf("Function should return param value")
}
}
func TestGetTestParamValue(t *testing.T) {
paramValue := "TEST_PARAM_VALUE"
value, err := getTestParamValue(paramValue)
if err != nil || value != paramValue {
t.Errorf("Function should return the same param value")
}
paramValue = "Something"
_, err = getTestParamValue(paramValue)
if err == nil {
t.Errorf("Function should return error if test-mode value is not passed")
}
}