Skip to content

utils package tests never run in CI, and three of them fail #1679

Description

@ihopenre-eng

Expected Behavior

make test covers the packages the CLI ships, and every test in the repository passes.

Actual Behavior

The test target runs ./pkg/... only:

test: test-deps
	gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-quiet -- ./pkg/... $(COVERAGE_OPTS)

./utils/... is therefore never executed by CI, and three of its tests fail today on a clean checkout of master:

$ go test ./utils/
--- FAIL: TestValidateFilePaths (0.00s)
    --- FAIL: TestValidateFilePaths/valid_file_path (0.00s)
--- FAIL: TestGetAbsPath (0.00s)
    --- FAIL: TestGetAbsPath/absolute_path (0.00s)
--- FAIL: TestReadFile (0.00s)
    --- FAIL: TestReadFile/valid_file_path (0.00s)
FAIL	github.com/dapr/cli/utils

Two of the three are not platform specific. TestValidateFilePaths and TestReadFile create a temp fixture and remove it with defer, while their subtests call t.Parallel(). A parallel subtest is paused until its parent function returns, so the deferred cleanup deletes the fixture before any subtest runs, and the "valid file path" cases end up asserting an error that only proves the file is already gone. Confirmed on linux/amd64 as well:

$ ./utils.test
--- FAIL: TestValidateFilePaths (0.01s)
--- FAIL: TestReadFile (0.00s)
FAIL

TestFindFileInDir in the same file already uses t.Cleanup for this reason.

TestGetAbsPath fails on Windows only: the "absolute path" case uses /absolute/path, which has no volume name, so filepath.IsAbs reports false for it and GetAbsPath joins it with baseDir.

Steps to Reproduce the Problem

  1. git clone https://github.com/dapr/cli && cd cli
  2. go test ./utils/

Release Note

RELEASE NOTE: FIX Broken tests in the utils package, and run that package in CI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions