@@ -2,6 +2,7 @@ package printer
22
33import (
44 "fmt"
5+ "strings"
56 "testing"
67
78 "github.com/gojek/feast/cli/feast/pkg/timeutil"
@@ -132,22 +133,51 @@ func TestPrintStorage(t *testing.T) {
132133 Spec : & specs.StorageSpec {
133134 Id : "REDIS1" ,
134135 Type : "redis" ,
135- Options : map [string ]string {
136- "option1" : "value1" ,
137- "option2" : "value2" ,
138- },
139136 },
140137 LastUpdated : & timestamp.Timestamp {Seconds : 1 },
141138 }
142139 out := PrintStorageDetail (storageDetail )
143140 expected := fmt .Sprintf (`Id: REDIS1
144141Type: redis
145142Options:
146- option1: value1
147- option2: value2
148143LastUpdated: %s` ,
149144 timeutil .FormatToRFC3339 (timestamp.Timestamp {Seconds : 1 }))
150145 if out != expected {
151146 t .Errorf ("Expected output:\n %s \n Actual:\n %s \n " , expected , out )
152147 }
153148}
149+
150+ func TestPrintStorageWithOptions (t * testing.T ) {
151+ storageDetail := & core.UIServiceTypes_StorageDetail {
152+ Spec : & specs.StorageSpec {
153+ Id : "REDIS1" ,
154+ Type : "redis" ,
155+ Options : map [string ]string {
156+ "option1" : "value1" ,
157+ "option2" : "value2" ,
158+ },
159+ },
160+ LastUpdated : & timestamp.Timestamp {Seconds : 1 },
161+ }
162+ out := PrintStorageDetail (storageDetail )
163+
164+ // Since map iteration order in Golang is radomized and "Options" is stored in a map,
165+ // this test just check that the output "contains" the key and value
166+ // rather than checking the exact match
167+
168+ expected := []string {
169+ "Id: REDIS1" ,
170+ "Type: redis" ,
171+ "Options:" ,
172+ " option1: value1" ,
173+ " option2: value2" ,
174+ fmt .Sprintf ("LastUpdated: %s" , timeutil .FormatToRFC3339 (timestamp.Timestamp {Seconds : 1 })),
175+ }
176+
177+ for _ , want := range expected {
178+ if ! strings .Contains (out , want ) {
179+ t .Errorf ("Missing \" %s\" from actual output\n Actual output:\n %s" , want , out )
180+ }
181+ }
182+
183+ }
0 commit comments