fix: 修复 config 测试因读取本机配置文件导致断言失败#62
Merged
riba2534 merged 1 commit intoriba2534:mainfrom Mar 29, 2026
Merged
Conversation
TestInit_DefaultValues reads ~/.feishu-cli/config.yaml if it exists, causing assertion failures on machines with a local config file. Set HOME to a temp dir so the test is environment-independent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestInit_DefaultValues因读取本机配置文件导致断言失败Background
本地环境有配置文件,运行测试用例时,会读取到配置文件的值,干扰用例结果。
TestInit_DefaultValues测试默认配置值,但未隔离 HOME 目录。当开发者本机存在~/.feishu-cli/config.yaml时,viper 会加载真实配置覆盖默认值,导致BaseURL等字段断言失败。测试结果取决于运行环境,不可复现。Changes
internal/config/config_test.got.TempDir(),测试结束后恢复Test Plan
常规检查
go build ./...编译通过go vet ./...静态检查通过go clean -testcache && go test ./...全部测试通过(含此前失败的TestInit_DefaultValues)变更用例
TestInit_DefaultValues