Skip to content

Commit 867928b

Browse files
authored
test(internal/sidekick): skip test instead of failing when cargo is not installed (#2102)
`go test ./...` should always pass on a fresh clone of github.com/librarian/googleapis. At the moment, TestRustProstFromProtobuf fails because it requires cargo. ``` --- FAIL: TestRustProstFromProtobuf (0.09s) sidekick_rust_prost_test.go:48: got an error trying to run `cargo --version`, the instructions on https://www.rust-lang.org/learn/get-started may solve this problem: cargo --version: exec: "cargo": executable file not found in $PATH ``` Skip this test when cargo is not installed.
1 parent 8eb879e commit 867928b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

internal/sidekick/sidekick_rust_prost_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
)
2222

2323
func TestRustProstFromProtobuf(t *testing.T) {
24+
requireCargo(t)
2425
requireProtoc(t)
2526
outDir := t.TempDir()
2627
svcConfig := path.Join(testdataDir, "googleapis/google/type/type.yaml")

internal/sidekick/sidekick_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,10 @@ func requireProtoc(t *testing.T) {
4141
t.Skip("skipping test because protoc is not installed")
4242
}
4343
}
44+
45+
func requireCargo(t *testing.T) {
46+
t.Helper()
47+
if _, err := exec.LookPath("cargo"); err != nil {
48+
t.Skip("skipping test because cargo is not installed")
49+
}
50+
}

0 commit comments

Comments
 (0)