Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7cb0eb0

Browse files
mirkoCrobumirkoCrobu
mirkoCrobu
authored and
mirkoCrobu
committed
refactoring store_test
1 parent90d6f29 commit7cb0eb0

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-24
lines changed

‎internal/store/store_test.go‎

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,16 @@ package store
22

33
import (
44
"os"
5-
"path/filepath"
65
"testing"
76

87
"github.com/arduino/go-paths-helper"
98
"github.com/stretchr/testify/require"
10-
11-
"github.com/arduino/arduino-app-cli/internal/orchestrator/config"
129
)
1310

1411
constvalidBrickID="arduino:arduino_cloud"
1512

16-
funcsetupTestStore(t*testing.T) (*StaticStore,string) {
17-
cfg,err:=config.NewFromEnv()
18-
require.NoError(t,err)
19-
baseDir:=paths.New("testdata","assets",cfg.RunnerVersion).String()
20-
returnNewStaticStore(baseDir),baseDir
21-
}
22-
2313
funcTestGetBrickReadmeFromID(t*testing.T) {
24-
store,baseDir:=setupTestStore(t)
25-
namespace,brickName,_:=parseBrickID(validBrickID)
26-
expectedReadmePath:=filepath.Join(baseDir,"docs",namespace,brickName,"README.md")
27-
expectedContent,err:=os.ReadFile(expectedReadmePath)
28-
require.NoError(t,err,"Error Reading README file: %s",expectedReadmePath)
29-
require.NotEmpty(t,expectedContent,"ReadME file is empty: %s",expectedReadmePath)
14+
store:=NewStaticStore(paths.New("testdata","assets","0.4.8").String())
3015

3116
testCases:= []struct {
3217
namestring
@@ -39,7 +24,7 @@ func TestGetBrickReadmeFromID(t *testing.T) {
3924
{
4025
name:"Success - file found",
4126
brickID:validBrickID,
42-
wantContent:string(expectedContent),
27+
wantContent:"## Readme test file",
4328
wantErr:false,
4429
},
4530
{
@@ -78,9 +63,7 @@ func TestGetBrickReadmeFromID(t *testing.T) {
7863
}
7964

8065
funcTestGetBrickComposeFilePathFromID(t*testing.T) {
81-
store,baseDir:=setupTestStore(t)
82-
namespace,brickName,_:=parseBrickID(validBrickID)
83-
expectedPathString:=filepath.Join(baseDir,"compose",namespace,brickName,"brick_compose.yaml")
66+
store:=NewStaticStore(paths.New("testdata","assets","0.4.8").String())
8467

8568
testCases:= []struct {
8669
namestring
@@ -92,7 +75,7 @@ func TestGetBrickComposeFilePathFromID(t *testing.T) {
9275
{
9376
name:"Success - valid ID",
9477
brickID:validBrickID,
95-
wantPath:expectedPathString,
78+
wantPath:"testdata/assets/0.4.8/compose/arduino/arduino_cloud/brick_compose.yaml",
9679
wantErr:false,
9780
},
9881
{
@@ -121,7 +104,7 @@ func TestGetBrickComposeFilePathFromID(t *testing.T) {
121104
}
122105

123106
funcTestGetBrickCodeExamplesPathFromID(t*testing.T) {
124-
store,_:=setupTestStore(t)
107+
store:=NewStaticStore(paths.New("testdata","assets","0.4.8").String())
125108
constexpectedEntryCount=2
126109

127110
testCases:= []struct {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
test file
1+
## brick composetest file
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
test file
1+
##Readmetest file

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp