Skip to content

Commit d7e520b

Browse files
authored
feat: return broken apps
1 parent 7761c8b commit d7e520b

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

internal/api/docs/openapi.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,11 @@ components:
12511251
$ref: '#/components/schemas/AppInfo'
12521252
nullable: true
12531253
type: array
1254+
broken_apps:
1255+
description: List of applications that are broken and couldn't be parsed
1256+
items:
1257+
$ref: '#/components/schemas/BrokenAppInfo'
1258+
type: array
12541259
type: object
12551260
AppPortResponse:
12561261
properties:
@@ -1370,6 +1375,13 @@ components:
13701375
required:
13711376
type: boolean
13721377
type: object
1378+
BrokenAppInfo:
1379+
properties:
1380+
error:
1381+
type: string
1382+
name:
1383+
type: string
1384+
type: object
13731385
CloneAppResponse:
13741386
properties:
13751387
id:

internal/api/handlers/app_list.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import (
1616
)
1717

1818
type AppListResponse struct {
19-
Apps []orchestrator.AppInfo `json:"apps" description:"List of applications"`
19+
Apps []orchestrator.AppInfo `json:"apps" description:"List of applications"`
20+
BrokenApps []orchestrator.BrokenAppInfo `json:"broken_apps,omitempty" description:"List of applications that are broken and couldn't be parsed"`
2021
}
2122

2223
func HandleAppList(
@@ -57,6 +58,6 @@ func HandleAppList(
5758

5859
return
5960
}
60-
render.EncodeResponse(w, http.StatusOK, AppListResponse{Apps: res.Apps})
61+
render.EncodeResponse(w, http.StatusOK, AppListResponse{Apps: res.Apps, BrokenApps: res.BrokenApps})
6162
}
6263
}

internal/e2e/client/client.gen.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/e2e/daemon/app_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package daemon
33
import (
44
"bufio"
55
"context"
6+
"encoding/base64"
67
"encoding/json"
78
"fmt"
89
"io"
@@ -19,6 +20,45 @@ import (
1920
"github.com/arduino/arduino-app-cli/internal/e2e/client"
2021
)
2122

23+
func TestApps(t *testing.T) {
24+
httpClient := GetHttpclient(t)
25+
26+
appName := "test-app-details"
27+
icon := "💻"
28+
createResp, err := httpClient.CreateAppWithResponse(
29+
t.Context(),
30+
&client.CreateAppParams{SkipSketch: f.Ptr(true)},
31+
client.CreateAppRequest{
32+
Icon: &icon,
33+
Name: appName,
34+
},
35+
)
36+
require.NoError(t, err)
37+
require.Equal(t, http.StatusCreated, createResp.StatusCode())
38+
require.NotNil(t, createResp.JSON201)
39+
fmt.Println(*createResp.JSON201.Id)
40+
fmt.Println(string(f.Must(base64.StdEncoding.DecodeString(*createResp.JSON201.Id))))
41+
appID := createResp.JSON201.Id
42+
43+
t.Run("ok", func(t *testing.T) {
44+
appsResp, err := httpClient.GetAppsWithResponse(t.Context(), &client.GetAppsParams{})
45+
require.NoError(t, err)
46+
require.Equal(t, http.StatusOK, appsResp.StatusCode())
47+
48+
require.NotNil(t, appsResp.JSON200.Apps)
49+
require.Len(t, *appsResp.JSON200.Apps, 1)
50+
51+
require.Equal(t, *appID, *(*appsResp.JSON200.Apps)[0].Id)
52+
require.Equal(t, appName, *(*appsResp.JSON200.Apps)[0].Name)
53+
require.Equal(t, icon, *(*appsResp.JSON200.Apps)[0].Icon)
54+
require.Equal(t, false, *(*appsResp.JSON200.Apps)[0].Example)
55+
require.Equal(t, false, *(*appsResp.JSON200.Apps)[0].Default)
56+
require.Equal(t, "", *(*appsResp.JSON200.Apps)[0].Description)
57+
58+
require.Nil(t, appsResp.JSON200.BrokenApps)
59+
})
60+
}
61+
2262
func TestCreateApp(t *testing.T) {
2363
httpClient := GetHttpclient(t)
2464

0 commit comments

Comments
 (0)