Skip to content

Commit 1a8fe30

Browse files
Improve style and readability
1 parent eb0b02b commit 1a8fe30

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

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

+16-21
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,8 @@ func TestInstallZipLibWithMacosMetadata(t *testing.T) {
11191119
// Verifies library is not already installed
11201120
require.NoDirExists(t, libInstallDir.String())
11211121

1122-
wd, err := paths.Getwd()
1122+
zipPath, err := paths.New("..", "testdata", "fake-lib.zip").Abs()
11231123
require.NoError(t, err)
1124-
zipPath := wd.Parent().Join("testdata", "fake-lib.zip")
11251124
// Test zip-path install
11261125
stdout, _, err := cli.Run("lib", "install", "--zip-path", zipPath.String())
11271126
require.NoError(t, err)
@@ -1156,9 +1155,8 @@ func TestInstallZipInvalidLibrary(t *testing.T) {
11561155
// Verifies library is not already installed
11571156
require.NoDirExists(t, libInstallDir.String())
11581157

1159-
wd, err := paths.Getwd()
1158+
zipPath, err := paths.New("..", "testdata", "lib-without-header.zip").Abs()
11601159
require.NoError(t, err)
1161-
zipPath := wd.Parent().Join("testdata", "lib-without-header.zip")
11621160
// Test zip-path install
11631161
_, stderr, err := cli.Run("lib", "install", "--zip-path", zipPath.String())
11641162
require.Error(t, err)
@@ -1168,7 +1166,8 @@ func TestInstallZipInvalidLibrary(t *testing.T) {
11681166
// Verifies library is not already installed
11691167
require.NoDirExists(t, libInstallDir.String())
11701168

1171-
zipPath = wd.Parent().Join("testdata", "lib-without-properties.zip")
1169+
zipPath, err = paths.New("..", "testdata", "lib-without-properties.zip").Abs()
1170+
require.NoError(t, err)
11721171
// Test zip-path install
11731172
_, stderr, err = cli.Run("lib", "install", "--zip-path", zipPath.String())
11741173
require.Error(t, err)
@@ -1192,7 +1191,7 @@ func TestInstallGitInvalidLibrary(t *testing.T) {
11921191
libProperties := repoDir.Join("library.properties")
11931192
f, err := libProperties.Create()
11941193
require.NoError(t, err)
1195-
f.Close()
1194+
require.NoError(t, f.Close())
11961195
tree, err := repo.Worktree()
11971196
require.NoError(t, err)
11981197
_, err = tree.Add("library.properties")
@@ -1218,7 +1217,7 @@ func TestInstallGitInvalidLibrary(t *testing.T) {
12181217
require.NoError(t, libHeader.Parent().MkdirAll())
12191218
f, err = libHeader.Create()
12201219
require.NoError(t, err)
1221-
f.Close()
1220+
require.NoError(t, f.Close())
12221221
tree, err = repo.Worktree()
12231222
require.NoError(t, err)
12241223
_, err = tree.Add("src/lib-without-properties.h")
@@ -1246,11 +1245,9 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibrariesInSketchbook(t *testing.T
12461245
require.NoError(t, platformInstallDir.Parent().MkdirAll())
12471246

12481247
// 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))
1248+
require.NoError(t, paths.New("..", "testdata", testPlatformName).CopyDirTo(platformInstallDir))
12521249

1253-
_, _, err = cli.Run("update")
1250+
_, _, err := cli.Run("update")
12541251
require.NoError(t, err)
12551252

12561253
// Install latest version of library identical to one
@@ -1262,8 +1259,8 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibrariesInSketchbook(t *testing.T
12621259
require.NoError(t, err)
12631260
requirejson.Len(t, stdout, 2)
12641261
// 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\"")
1262+
requirejson.Query(t, stdout, ".[0] | .library | .name", `"USBHost"`)
1263+
requirejson.Query(t, stdout, ".[1] | .library | .name", `"USBHost"`)
12671264

12681265
stdout, _, err = cli.Run("lib", "upgrade")
12691266
require.NoError(t, err)
@@ -1280,11 +1277,9 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibraries(t *testing.T) {
12801277
require.NoError(t, platformInstallDir.Parent().MkdirAll())
12811278

12821279
// 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))
1280+
require.NoError(t, paths.New("..", "testdata", testPlatformName).CopyDirTo(platformInstallDir))
12861281

1287-
_, _, err = cli.Run("update")
1282+
_, _, err := cli.Run("update")
12881283
require.NoError(t, err)
12891284

12901285
// Install latest version of library identical to one
@@ -1296,8 +1291,8 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibraries(t *testing.T) {
12961291
require.NoError(t, err)
12971292
requirejson.Len(t, stdout, 2)
12981293
// 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\"")
1294+
requirejson.Query(t, stdout, ".[0] | .library | .name", `"USBHost"`)
1295+
requirejson.Query(t, stdout, ".[1] | .library | .name", `"USBHost"`)
13011296

13021297
stdout, _, err = cli.Run("lib", "upgrade")
13031298
require.NoError(t, err)
@@ -1472,7 +1467,7 @@ func TestInstallWithGitUrlLocalFileUri(t *testing.T) {
14721467
})
14731468
require.NoError(t, err)
14741469

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

14781473
// Verifies library is installed

0 commit comments

Comments
 (0)