Skip to content

Commit c0dcc38

Browse files
Improve style and readability
1 parent eb0b02b commit c0dcc38

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

Diff for: internal/integrationtest/lib/lib_test.go

+15-23
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ func TestLibCommandsWithLibraryHavingInvalidVersion(t *testing.T) {
10811081
stdout, _, err := cli.Run("lib", "list", "--format", "json")
10821082
require.NoError(t, err)
10831083
requirejson.Len(t, stdout, 1)
1084-
requirejson.Query(t, stdout, ".[0] | .library | .version", "\"0.16.1\"")
1084+
requirejson.Query(t, stdout, ".[0] | .library | .version", `"0.16.1"`)
10851085

10861086
// Changes the version of the currently installed library so that it's
10871087
// invalid
@@ -1119,9 +1119,7 @@ func TestInstallZipLibWithMacosMetadata(t *testing.T) {
11191119
// Verifies library is not already installed
11201120
require.NoDirExists(t, libInstallDir.String())
11211121

1122-
wd, err := paths.Getwd()
1123-
require.NoError(t, err)
1124-
zipPath := wd.Parent().Join("testdata", "fake-lib.zip")
1122+
zipPath := paths.New("..", "testdata", "fake-lib.zip")
11251123
// Test zip-path install
11261124
stdout, _, err := cli.Run("lib", "install", "--zip-path", zipPath.String())
11271125
require.NoError(t, err)
@@ -1156,9 +1154,7 @@ func TestInstallZipInvalidLibrary(t *testing.T) {
11561154
// Verifies library is not already installed
11571155
require.NoDirExists(t, libInstallDir.String())
11581156

1159-
wd, err := paths.Getwd()
1160-
require.NoError(t, err)
1161-
zipPath := wd.Parent().Join("testdata", "lib-without-header.zip")
1157+
zipPath := paths.New("..", "testdata", "lib-without-header.zip")
11621158
// Test zip-path install
11631159
_, stderr, err := cli.Run("lib", "install", "--zip-path", zipPath.String())
11641160
require.Error(t, err)
@@ -1168,7 +1164,7 @@ func TestInstallZipInvalidLibrary(t *testing.T) {
11681164
// Verifies library is not already installed
11691165
require.NoDirExists(t, libInstallDir.String())
11701166

1171-
zipPath = wd.Parent().Join("testdata", "lib-without-properties.zip")
1167+
zipPath = paths.New("..", "testdata", "lib-without-properties.zip")
11721168
// Test zip-path install
11731169
_, stderr, err = cli.Run("lib", "install", "--zip-path", zipPath.String())
11741170
require.Error(t, err)
@@ -1192,7 +1188,7 @@ func TestInstallGitInvalidLibrary(t *testing.T) {
11921188
libProperties := repoDir.Join("library.properties")
11931189
f, err := libProperties.Create()
11941190
require.NoError(t, err)
1195-
f.Close()
1191+
require.NoError(t, f.Close())
11961192
tree, err := repo.Worktree()
11971193
require.NoError(t, err)
11981194
_, err = tree.Add("library.properties")
@@ -1218,7 +1214,7 @@ func TestInstallGitInvalidLibrary(t *testing.T) {
12181214
require.NoError(t, libHeader.Parent().MkdirAll())
12191215
f, err = libHeader.Create()
12201216
require.NoError(t, err)
1221-
f.Close()
1217+
require.NoError(t, f.Close())
12221218
tree, err = repo.Worktree()
12231219
require.NoError(t, err)
12241220
_, err = tree.Add("src/lib-without-properties.h")
@@ -1246,11 +1242,9 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibrariesInSketchbook(t *testing.T
12461242
require.NoError(t, platformInstallDir.Parent().MkdirAll())
12471243

12481244
// Install platform in Sketchbook hardware dir
1249-
wd, err := paths.Getwd()
1250-
require.NoError(t, err)
1251-
require.NoError(t, wd.Parent().Join("testdata", testPlatformName).CopyDirTo(platformInstallDir))
1245+
require.NoError(t, paths.New("..", "testdata", testPlatformName).CopyDirTo(platformInstallDir))
12521246

1253-
_, _, err = cli.Run("update")
1247+
_, _, err := cli.Run("update")
12541248
require.NoError(t, err)
12551249

12561250
// Install latest version of library identical to one
@@ -1262,8 +1256,8 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibrariesInSketchbook(t *testing.T
12621256
require.NoError(t, err)
12631257
requirejson.Len(t, stdout, 2)
12641258
// Verify both libraries have the same name
1265-
requirejson.Query(t, stdout, ".[0] | .library | .name", "\"USBHost\"")
1266-
requirejson.Query(t, stdout, ".[1] | .library | .name", "\"USBHost\"")
1259+
requirejson.Query(t, stdout, ".[0] | .library | .name", `"USBHost"`)
1260+
requirejson.Query(t, stdout, ".[1] | .library | .name", `"USBHost"`)
12671261

12681262
stdout, _, err = cli.Run("lib", "upgrade")
12691263
require.NoError(t, err)
@@ -1280,11 +1274,9 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibraries(t *testing.T) {
12801274
require.NoError(t, platformInstallDir.Parent().MkdirAll())
12811275

12821276
// Install platform in Sketchbook hardware dir
1283-
wd, err := paths.Getwd()
1284-
require.NoError(t, err)
1285-
require.NoError(t, wd.Parent().Join("testdata", testPlatformName).CopyDirTo(platformInstallDir))
1277+
require.NoError(t, paths.New("..", "testdata", testPlatformName).CopyDirTo(platformInstallDir))
12861278

1287-
_, _, err = cli.Run("update")
1279+
_, _, err := cli.Run("update")
12881280
require.NoError(t, err)
12891281

12901282
// Install latest version of library identical to one
@@ -1296,8 +1288,8 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibraries(t *testing.T) {
12961288
require.NoError(t, err)
12971289
requirejson.Len(t, stdout, 2)
12981290
// Verify both libraries have the same name
1299-
requirejson.Query(t, stdout, ".[0] | .library | .name", "\"USBHost\"")
1300-
requirejson.Query(t, stdout, ".[1] | .library | .name", "\"USBHost\"")
1291+
requirejson.Query(t, stdout, ".[0] | .library | .name", `"USBHost"`)
1292+
requirejson.Query(t, stdout, ".[1] | .library | .name", `"USBHost"`)
13011293

13021294
stdout, _, err = cli.Run("lib", "upgrade")
13031295
require.NoError(t, err)
@@ -1472,7 +1464,7 @@ func TestInstallWithGitUrlLocalFileUri(t *testing.T) {
14721464
})
14731465
require.NoError(t, err)
14741466

1475-
_, _, err = cli.RunWithCustomEnv(envVar, "lib", "install", "--git-url", "file:///"+repoDir.String())
1467+
_, _, err = cli.RunWithCustomEnv(envVar, "lib", "install", "--git-url", "file://"+repoDir.String())
14761468
require.NoError(t, err)
14771469

14781470
// Verifies library is installed

0 commit comments

Comments
 (0)