Skip to content

Commit 1306f0e

Browse files
committed
add tests
1 parent 15fcb43 commit 1306f0e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

main_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,19 @@ func TestInstallToolV2(t *testing.T) {
168168
})
169169
}
170170
}
171+
172+
func TestInstalledHead(t *testing.T) {
173+
indexURL := "https://downloads.arduino.cc/packages/package_staging_index.json"
174+
// Instantiate Index
175+
Index := index.Init(indexURL, config.GetDataDir())
176+
177+
r := gin.New()
178+
goa := v2.Server(config.GetDataDir().String(), Index)
179+
r.Any("/v2/*path", gin.WrapH(goa))
180+
ts := httptest.NewServer(r)
181+
182+
resp, err := http.Head(ts.URL + "/v2/pkgs/tools/installed")
183+
require.NoError(t, err)
184+
require.NotEqual(t, resp.StatusCode, http.StatusMethodNotAllowed)
185+
require.Equal(t, resp.StatusCode, http.StatusOK)
186+
}

v2/pkgs/tools_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,22 @@ func TestEvilFilename(t *testing.T) {
185185
}
186186
}
187187

188+
func TestInstalledHead(t *testing.T) {
189+
// Initialize indexes with a temp folder
190+
tmp := t.TempDir()
191+
192+
indexURL := "https://downloads.arduino.cc/packages/package_staging_index.json"
193+
// Instantiate Index
194+
Index := index.Init(indexURL, config.GetDataDir())
195+
196+
service := pkgs.New(Index, tmp)
197+
198+
ctx := context.Background()
199+
200+
err := service.Installedhead(ctx)
201+
require.NoError(t, err)
202+
}
203+
188204
func strpoint(s string) *string {
189205
return &s
190206
}

0 commit comments

Comments
 (0)