@@ -13,6 +13,7 @@ import (
1313type variableEntry struct {
1414 name string
1515 value string
16+ found bool
1617 description string
1718}
1819
@@ -27,41 +28,46 @@ func renderVariableSection(title string, entries []variableEntry) string {
2728 var str strings.Builder
2829 fmt .Fprintf (& str , " %s: \n " , title )
2930 for _ , entry := range entries {
30- fmt .Fprintf (& str , " - %s: %s (%s)\n " , entry .name , formatVariableValue (entry .value ), entry .description )
31+ fmt .Fprintf (& str , " - %s: %s (%s)\n " , entry .name , formatVariableValue (entry .value , entry . found ), entry .description )
3132 }
3233 return str .String ()
3334}
3435
35- func formatVariableValue (value string ) string {
36- if value == "" {
36+ func formatVariableValue (value string , found bool ) string {
37+ if ! found {
3738 return "[not found]"
3839 }
40+ if value == "" {
41+ return "[empty]"
42+ }
3943 return value
4044}
4145
4246func savedVariablesForHTTPResult (result api.HTTPRequestResult ) []variableEntry {
4347 var entries []variableEntry
4448 for _ , responseVariable := range result .Request .ResponseVariables {
45- value := result .Variables [responseVariable .Name ]
46- if value == "" {
49+ value , found := result .Variables [responseVariable .Name ]
50+ if ! found {
4751 continue
4852 }
4953
5054 description := responseVariableDescription (responseVariable )
5155 entries = append (entries , variableEntry {
5256 name : responseVariable .Name ,
5357 value : value ,
58+ found : true ,
5459 description : description ,
5560 })
5661 }
5762 for _ , responseHeaderVariable := range result .Request .ResponseHeaderVariables {
58- value := result .Variables [responseHeaderVariable .Name ]
59- if value == "" {
63+ value , found := result .Variables [responseHeaderVariable .Name ]
64+ if ! found {
6065 continue
6166 }
6267 entries = append (entries , variableEntry {
6368 name : responseHeaderVariable .Name ,
6469 value : value ,
70+ found : true ,
6571 description : responseHeaderVariableDescription (responseHeaderVariable ),
6672 })
6773 }
@@ -71,7 +77,7 @@ func savedVariablesForHTTPResult(result api.HTTPRequestResult) []variableEntry {
7177func missingSaveVariablesForHTTPResult (result api.HTTPRequestResult ) []variableEntry {
7278 var entries []variableEntry
7379 for _ , responseVariable := range result .Request .ResponseVariables {
74- if result .Variables [responseVariable .Name ] != "" {
80+ if _ , found := result .Variables [responseVariable .Name ]; found {
7581 continue
7682 }
7783
@@ -82,7 +88,7 @@ func missingSaveVariablesForHTTPResult(result api.HTTPRequestResult) []variableE
8288 })
8389 }
8490 for _ , responseHeaderVariable := range result .Request .ResponseHeaderVariables {
85- if result .Variables [responseHeaderVariable .Name ] != "" {
91+ if _ , found := result .Variables [responseHeaderVariable .Name ]; found {
8692 continue
8793 }
8894 entries = append (entries , variableEntry {
@@ -108,7 +114,7 @@ func availableVariablesForHTTPResult(result api.HTTPRequestResult) (entries []va
108114 return
109115 }
110116 expectsVariables = true
111- value := result .Variables [name ]
117+ value , found := result .Variables [name ]
112118 key := name + "\x00 " + description
113119 if seen [key ] {
114120 return
@@ -117,6 +123,7 @@ func availableVariablesForHTTPResult(result api.HTTPRequestResult) (entries []va
117123 entries = append (entries , variableEntry {
118124 name : name ,
119125 value : value ,
126+ found : found ,
120127 description : description ,
121128 })
122129 }
@@ -167,7 +174,7 @@ func availableVariablesForCLIResult(result api.CLICommandResult) (entries []vari
167174
168175 add := func (name , description string ) {
169176 expectsVariables = true
170- value := result .Variables [name ]
177+ value , found := result .Variables [name ]
171178 key := name + "\x00 " + description
172179 if seen [key ] {
173180 return
@@ -176,6 +183,7 @@ func availableVariablesForCLIResult(result api.CLICommandResult) (entries []vari
176183 entries = append (entries , variableEntry {
177184 name : name ,
178185 value : value ,
186+ found : found ,
179187 description : description ,
180188 })
181189 }
0 commit comments