Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(envfile_test): Fix unit test error in Windows #43

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

LightAPIs
Copy link

该问题仅存在于 Windows 系统中。

问题现象

在 Windows 系统下运行 go test 进行单元测试时无法通过,但在 Linux 系统下则正常。

调试后发现 os.Remove(envPath) 等方法在 Windows 中并没有删除文件,而是报错:

The process cannot access the file because it is being used by another process.

从而导致某些依赖于不存在 .env 文件的单元测试无法通过。

问题原因

Windows 系统不允许直接删除已打开的文件。

解决方法

envfile_test 中删除 .env 文件前关闭文件。

测试在进行该处理之后在,于 Windows 和 Liunx 下的单元测试均可正常通过了。

Copy link
Owner

@soulteary soulteary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@soulteary soulteary merged commit 71bbc47 into soulteary:main Jan 31, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants