Skip to content

Commit 8ca8e18

Browse files
committed
add test
1 parent c7f8df6 commit 8ca8e18

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

index/index_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package index
2+
3+
import (
4+
"net/url"
5+
"testing"
6+
7+
"github.com/arduino/go-paths-helper"
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestInit(t *testing.T) {
12+
indexURL := "https://downloads.arduino.cc/packages/package_staging_index.json"
13+
// Instantiate Index
14+
tempDir := paths.New(t.TempDir()).Join(".arduino-create")
15+
Index := Init(indexURL, tempDir)
16+
require.DirExists(t, tempDir.String())
17+
fileName := "package_staging_index.json"
18+
signatureName := fileName + ".sig"
19+
parsedURL, _ := url.Parse(indexURL)
20+
require.Equal(t, Index.IndexURL, *parsedURL)
21+
require.Contains(t, Index.IndexFile.String(), fileName)
22+
require.Contains(t, Index.IndexSignature.String(), signatureName)
23+
require.FileExists(t, tempDir.Join(fileName).String())
24+
require.FileExists(t, tempDir.Join(signatureName).String())
25+
}

0 commit comments

Comments
 (0)