@@ -27,26 +27,26 @@ func Test_VersionCommandOutputFormat(t *testing.T) {
2727 require .NoError (t , err , "brev --version command should succeed" )
2828
2929 outputStr := string (output )
30-
30+
3131 // Test 1: Version should contain "Current version:" or "Current Version:" prefix
3232 hasVersionPrefix := strings .Contains (outputStr , "Current Version:" ) || strings .Contains (outputStr , "Current version:" )
3333 assert .True (t , hasVersionPrefix , "Version output should contain 'Current Version:' or 'Current version:' prefix" )
34-
34+
3535 // Test 2: Should contain a version number in X.Y.Z format (may be empty in dev builds)
3636 versionRegex := regexp .MustCompile (`(\d+\.\d+\.\d+)` )
3737 matches := versionRegex .FindAllString (outputStr , - 1 )
38-
38+
3939 // In dev environments, current version might be empty, but there should be a "New Version:" mentioned
4040 if len (matches ) == 0 {
4141 // Check if this is a dev build scenario where current version is empty
42- assert .True (t , strings .Contains (outputStr , "New Version:" ),
42+ assert .True (t , strings .Contains (outputStr , "New Version:" ),
4343 "If no current version found, should show available version for upgrade" )
4444 } else {
4545 // If we found version numbers, verify the first one is properly formatted
4646 versionStr := matches [0 ]
4747 versionParts := strings .Split (versionStr , "." )
4848 assert .Len (t , versionParts , 3 , "Version should have exactly 3 components" )
49-
49+
5050 for i , part := range versionParts {
5151 _ , err := strconv .Atoi (part )
5252 assert .NoError (t , err , "Version part %d (%s) should be a valid integer" , i , part )
@@ -59,12 +59,12 @@ func Test_OrgListCommandOutputFormat(t *testing.T) {
5959 // Note: This test may require authentication, so we'll test the format when orgs exist
6060 cmd := exec .Command ("go" , "run" , "../../main.go" , "org" , "ls" )
6161 output , err := cmd .CombinedOutput ()
62-
62+
6363 // Command might fail due to auth issues, but if it succeeds, check format
6464 if err == nil {
6565 outputStr := string (output )
6666 lines := strings .Split (outputStr , "\n " )
67-
67+
6868 // Look for table header format
6969 var foundHeader bool
7070 var headerLineIdx int
@@ -75,13 +75,13 @@ func Test_OrgListCommandOutputFormat(t *testing.T) {
7575 break
7676 }
7777 }
78-
78+
7979 if foundHeader {
8080 // Test table header format
8181 headerLine := lines [headerLineIdx ]
8282 assert .Contains (t , headerLine , "NAME" , "Org list should have NAME column" )
8383 assert .Contains (t , headerLine , "ID" , "Org list should have ID column" )
84-
84+
8585 // Test that current org is marked with "*" prefix if there are data rows
8686 for i := headerLineIdx + 1 ; i < len (lines ); i ++ {
8787 line := strings .TrimSpace (lines [i ])
@@ -102,38 +102,38 @@ func Test_OrgListCommandOutputFormat(t *testing.T) {
102102func Test_InstanceListCommandOutputFormat (t * testing.T ) {
103103 cmd := exec .Command ("go" , "run" , "../../main.go" , "ls" )
104104 output , err := cmd .CombinedOutput ()
105-
105+
106106 // Command might fail due to auth issues, but if it succeeds, check format
107107 if err == nil {
108108 outputStr := string (output )
109109 lines := strings .Split (outputStr , "\n " )
110-
110+
111111 // Look for table header format
112112 var foundHeader bool
113113 var headerLineIdx int
114114 for i , line := range lines {
115- if strings .Contains (line , "NAME" ) && strings .Contains (line , "STATUS" ) &&
116- strings .Contains (line , "ID" ) && strings .Contains (line , "MACHINE" ) {
115+ if strings .Contains (line , "NAME" ) && strings .Contains (line , "STATUS" ) &&
116+ strings .Contains (line , "ID" ) && strings .Contains (line , "MACHINE" ) {
117117 foundHeader = true
118118 headerLineIdx = i
119119 break
120120 }
121121 }
122-
122+
123123 if foundHeader {
124124 // Test required columns exist
125125 headerLine := lines [headerLineIdx ]
126126 assert .Contains (t , headerLine , "NAME" , "Instance list should have NAME column" )
127- assert .Contains (t , headerLine , "STATUS" , "Instance list should have STATUS column" )
127+ assert .Contains (t , headerLine , "STATUS" , "Instance list should have STATUS column" )
128128 assert .Contains (t , headerLine , "ID" , "Instance list should have ID column" )
129129 assert .Contains (t , headerLine , "MACHINE" , "Instance list should have MACHINE column" )
130-
130+
131131 // Test column positions for parsing (important for external integrations)
132132 namePos := strings .Index (headerLine , "NAME" )
133133 statusPos := strings .Index (headerLine , "STATUS" )
134134 idPos := strings .Index (headerLine , "ID" )
135135 machinePos := strings .Index (headerLine , "MACHINE" )
136-
136+
137137 assert .GreaterOrEqual (t , statusPos , namePos , "STATUS column should come after NAME" )
138138 assert .GreaterOrEqual (t , idPos , statusPos , "ID column should come after STATUS" )
139139 assert .GreaterOrEqual (t , machinePos , idPos , "MACHINE column should come after ID" )
@@ -145,22 +145,22 @@ func Test_InstanceListCommandOutputFormat(t *testing.T) {
145145func Test_RefreshCommandExists (t * testing.T ) {
146146 cmd := exec .Command ("go" , "run" , "../../main.go" , "refresh" , "--help" )
147147 output , _ := cmd .CombinedOutput ()
148-
148+
149149 // Should succeed or fail with auth, but not with "command not found"
150150 outputStr := string (output )
151151 assert .NotContains (t , outputStr , "unknown command" , "refresh command should exist" )
152152 assert .NotContains (t , outputStr , "command not found" , "refresh command should exist" )
153153}
154154
155- // Test_OrgSetCommandExists verifies that 'brev org set' command exists and is callable
155+ // Test_OrgSetCommandExists verifies that 'brev org set' command exists and is callable
156156func Test_OrgSetCommandExists (t * testing.T ) {
157157 cmd := exec .Command ("go" , "run" , "../../main.go" , "org" , "set" , "--help" )
158158 output , _ := cmd .CombinedOutput ()
159-
159+
160160 // Should succeed with help output or show that command exists
161161 outputStr := string (output )
162162 // Command exists if it shows help or mentions "set" functionality
163- hasSetCommand := strings .Contains (outputStr , "set" ) ||
163+ hasSetCommand := strings .Contains (outputStr , "set" ) ||
164164 strings .Contains (outputStr , "organization" ) ||
165165 ! strings .Contains (outputStr , "unknown command" )
166166 assert .True (t , hasSetCommand , "org set command should exist and be callable" )
@@ -170,10 +170,10 @@ func Test_OrgSetCommandExists(t *testing.T) {
170170func Test_StartCommandFormat (t * testing.T ) {
171171 cmd := exec .Command ("go" , "run" , "../../main.go" , "start" , "--help" )
172172 output , _ := cmd .CombinedOutput ()
173-
173+
174174 outputStr := string (output )
175175 // Should mention org flag or organization, or at least not be unknown command
176- hasOrgSupport := strings .Contains (outputStr , "--org" ) ||
176+ hasOrgSupport := strings .Contains (outputStr , "--org" ) ||
177177 strings .Contains (outputStr , "organization" ) ||
178178 (strings .Contains (outputStr , "start" ) && ! strings .Contains (outputStr , "unknown command" ))
179179 assert .True (t , hasOrgSupport , "start command should exist and potentially support org specification" )
@@ -183,10 +183,10 @@ func Test_StartCommandFormat(t *testing.T) {
183183func Test_StopCommandExists (t * testing.T ) {
184184 cmd := exec .Command ("go" , "run" , "../../main.go" , "stop" , "--help" )
185185 output , _ := cmd .CombinedOutput ()
186-
186+
187187 outputStr := string (output )
188188 // Command exists if it shows help or mentions "stop" functionality
189- hasStopCommand := strings .Contains (outputStr , "stop" ) ||
189+ hasStopCommand := strings .Contains (outputStr , "stop" ) ||
190190 ! strings .Contains (outputStr , "unknown command" )
191191 assert .True (t , hasStopCommand , "stop command should exist" )
192192}
@@ -197,14 +197,14 @@ func Test_APIInstanceTypesEndpoint(t *testing.T) {
197197 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
198198 // Test 1: Correct endpoint path
199199 assert .Equal (t , "/v1/instance/types" , r .URL .Path , "API should call correct endpoint" )
200-
200+
201201 // Test 2: Expected User-Agent (this is what external integrations set)
202202 expectedUserAgent := "nvidia-ai-workbench"
203203 actualUserAgent := r .Header .Get ("User-Agent" )
204204 if actualUserAgent != "" {
205205 assert .Equal (t , expectedUserAgent , actualUserAgent , "API should use expected User-Agent" )
206206 }
207-
207+
208208 // Test 3: Return expected response format
209209 response := struct {
210210 Items []struct {
@@ -221,7 +221,7 @@ func Test_APIInstanceTypesEndpoint(t *testing.T) {
221221 {Type : "t3.medium" , Stoppable : true },
222222 },
223223 }
224-
224+
225225 w .Header ().Set ("Content-Type" , "application/json" )
226226 err := json .NewEncoder (w ).Encode (response )
227227 if err != nil {
@@ -230,37 +230,37 @@ func Test_APIInstanceTypesEndpoint(t *testing.T) {
230230 }
231231 }))
232232 defer server .Close ()
233-
233+
234234 // Test the API endpoint
235235 client := & http.Client {Timeout : 5 * time .Second }
236236 ctx := context .Background ()
237237 req , err := http .NewRequestWithContext (ctx , "GET" , server .URL + "/v1/instance/types" , nil )
238238 require .NoError (t , err )
239-
239+
240240 req .Header .Set ("User-Agent" , "nvidia-ai-workbench" )
241-
241+
242242 resp , err := client .Do (req )
243243 require .NoError (t , err )
244244 defer func () {
245245 if closeErr := resp .Body .Close (); closeErr != nil {
246246 t .Logf ("Failed to close response body: %v" , closeErr )
247247 }
248248 }()
249-
249+
250250 assert .Equal (t , 200 , resp .StatusCode , "API should return 200 OK" )
251251 assert .Equal (t , "application/json" , resp .Header .Get ("Content-Type" ), "API should return JSON" )
252-
252+
253253 // Test response parsing
254254 var response struct {
255255 Items []struct {
256256 Type string `json:"type"`
257257 Stoppable bool `json:"stoppable"`
258258 } `json:"items"`
259259 }
260-
260+
261261 err = json .NewDecoder (resp .Body ).Decode (& response )
262262 require .NoError (t , err , "Response should be valid JSON" )
263-
263+
264264 assert .NotEmpty (t , response .Items , "Response should contain items" )
265265 for _ , item := range response .Items {
266266 assert .NotEmpty (t , item .Type , "Each item should have a type" )
@@ -274,9 +274,9 @@ func Test_CommandLineInterfaceStability(t *testing.T) {
274274 cmd := exec .Command ("go" , "run" , "../../main.go" , "--help" )
275275 output , err := cmd .CombinedOutput ()
276276 require .NoError (t , err , "brev --help should work" )
277-
277+
278278 outputStr := string (output )
279-
279+
280280 // Essential commands should be listed in help
281281 essentialCommands := []string {"ls" , "org" , "start" , "stop" , "refresh" }
282282 for _ , command := range essentialCommands {
@@ -317,35 +317,35 @@ func Test_VersionParsingCompatibility(t *testing.T) {
317317 shouldError : false ,
318318 },
319319 }
320-
320+
321321 // Minimum version that external integrations expect
322322 minBrevVersion := "0.6.306"
323-
323+
324324 for _ , tc := range testCases {
325325 t .Run (tc .name , func (t * testing.T ) {
326326 // Extract version using same regex external tools use
327327 versionRegEx := regexp .MustCompile (`(\d+\.\d+\.\d+)` )
328328 versionStr := versionRegEx .FindString (tc .versionOutput )
329-
329+
330330 if tc .shouldError {
331331 assert .Empty (t , versionStr , "Should not find version in malformed output" )
332332 return
333333 }
334-
334+
335335 assert .NotEmpty (t , versionStr , "Should find version number" )
336-
336+
337337 // Compare version parts (same logic as external integration)
338338 installedVersionComponents := strings .Split (versionStr , "." )
339339 minVersionComponents := strings .Split (minBrevVersion , "." )
340-
340+
341341 needsUpgrade := false
342342 for i := range installedVersionComponents {
343343 installed , err := strconv .Atoi (installedVersionComponents [i ])
344344 require .NoError (t , err , "Version component should be integer" )
345-
345+
346346 desired , err := strconv .Atoi (minVersionComponents [i ])
347347 require .NoError (t , err , "Min version component should be integer" )
348-
348+
349349 if installed < desired {
350350 needsUpgrade = true
351351 break
@@ -354,9 +354,9 @@ func Test_VersionParsingCompatibility(t *testing.T) {
354354 break
355355 }
356356 }
357-
358- assert .Equal (t , tc .expectsUpgrade , needsUpgrade ,
357+
358+ assert .Equal (t , tc .expectsUpgrade , needsUpgrade ,
359359 "Version upgrade requirement should match expected for %s" , versionStr )
360360 })
361361 }
362- }
362+ }
0 commit comments