forked from aws/aws-sam-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparams_test.go
47 lines (37 loc) · 1.51 KB
/
params_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 (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Parse Cloudformation parameters", func() {
Context("with normal input", func() {
It("returns empty map when input is missing", func() {
p := parseParameters("")
Expect(p).To(BeEmpty())
})
It("returns expected values when input is correct", func() {
p := parseParameters("ParameterKey=KeyPairName,ParameterValue=MyKey ParameterKey=InstanceType,ParameterValue=t1.micro")
Expect(p).To(HaveLen(2))
Expect(p).To(HaveKeyWithValue("KeyPairName", "MyKey"))
Expect(p).To(HaveKeyWithValue("InstanceType", "t1.micro"))
})
It("returns partial values when input is malformed", func() {
p := parseParameters("ParameterKey=KeyPairName,ParameterValue=MyKey Para")
Expect(p).To(HaveLen(1))
Expect(p).To(HaveKeyWithValue("KeyPairName", "MyKey"))
})
})
Context("with escaped input", func() {
It("returns expected values when keys or values are quoted", func() {
p := parseParameters(`ParameterKey="KeyPairName",ParameterValue="MyKey " ParameterKey=InstanceType,ParameterValue=t1\ mic\ ro`)
Expect(p).To(HaveLen(2))
Expect(p).To(HaveKeyWithValue("KeyPairName", "MyKey "))
Expect(p).To(HaveKeyWithValue("InstanceType", "t1 mic ro"))
})
It("handles wrong quotings", func() {
p := parseParameters(`ParameterKey="KeyPairName,ParameterValue="MyKey" ParameterKey=InstanceType,ParameterValue=t1\ micro`)
Expect(p).To(HaveLen(1))
Expect(p).To(HaveKeyWithValue("InstanceType", "t1 micro"))
})
})
})