File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -112,14 +112,26 @@ func TestGetComponent(t *testing.T) {
112112}
113113
114114func TestLoadState (t * testing.T ) {
115+ testLoadStateWithResponse (t , func (w http.ResponseWriter , r * http.Request ) {
116+ fmt .Fprint (w , "{\" components\" : [],\" version\" : \" 0.3.0\" }" )
117+ })
118+ }
119+
120+ func TestLoadStateWithTwoFailures (t * testing.T ) {
121+ failed := 0
122+ testLoadStateWithResponse (t , func (w http.ResponseWriter , r * http.Request ) {
123+ if failed < 2 {
124+ failed += 1
125+ return
126+ }
127+ fmt .Fprint (w , "{\" components\" : [],\" version\" : \" 0.3.0\" }" )
128+ })
129+ }
130+
131+ func testLoadStateWithResponse (t * testing.T , response func (http.ResponseWriter , * http.Request )) {
115132 fakeServer := lacework .MockServer ()
116133 fakeServer .UseApiV2 ()
117- fakeServer .MockAPI (
118- "Components" ,
119- func (w http.ResponseWriter , r * http.Request ) {
120- fmt .Fprint (w , "{\" components\" : [],\" version\" : \" 0.3.0\" }" )
121- },
122- )
134+ fakeServer .MockAPI ("Components" , response )
123135 defer fakeServer .Close ()
124136
125137 c , err := api .NewClient ("test" ,
You can’t perform that action at this time.
0 commit comments