Skip to content

Commit

Permalink
fix(envfile_test): Fix unit test error in Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Light authored and Light committed Jan 6, 2024
1 parent 81a313a commit 810873d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/envfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ func TestCheckDotEnvFileExist(t *testing.T) {

// test .env exist
f, _ := os.Create(envPath)
defer os.Remove(f.Name())
filename := f.Name()
defer os.Remove(filename)
defer f.Close()
assert.Equal(t, FlareCMD.CheckDotEnvFileExist(envPath), true)
}

Expand Down Expand Up @@ -65,6 +67,7 @@ func TestParseEnvFile_ParseErr(t *testing.T) {
// test .env auto correct
f, _ := os.Create(envPath)
defer os.Remove(envPath)
defer f.Close()
f.Write([]byte("FLARE_PORT=true\nFLARE_USER=\nFLARE_PASS=\nFLARE_GUIDE=1111"))
flags := FlareCMD.ParseEnvFile(envParsed)
assert.Equal(t, flags, envParsed)
Expand All @@ -85,6 +88,7 @@ func TestParseEnvFile_ParseOverwrite(t *testing.T) {
// test .env auto correct
f, _ := os.Create(envPath)
defer os.Remove(envPath)
defer f.Close()
f.Write([]byte("FLARE_PORT=2345\nFLARE_USER=\nFLARE_PASS=\nFLARE_GUIDE=false"))
flags := FlareCMD.ParseEnvFile(envParsed)

Expand All @@ -109,6 +113,7 @@ func TestParseEnvFile_PortError(t *testing.T) {
// test .env auto correct
f, _ := os.Create(envPath)
defer os.Remove(envPath)
defer f.Close()
f.Write([]byte("FLARE_PORT=9999999\nFLARE_USER=\nFLARE_PASS=\nFLARE_GUIDE=false"))
flags := FlareCMD.ParseEnvFile(envParsed)

Expand All @@ -133,6 +138,7 @@ func TestParseEnvFile_User(t *testing.T) {
// test .env auto correct
f, _ := os.Create(envPath)
defer os.Remove(envPath)
defer f.Close()
f.Write([]byte("FLARE_PORT=5005\nFLARE_USER=flare\nFLARE_PASS=\n"))
flags := FlareCMD.ParseEnvFile(envParsed)

Expand Down

0 comments on commit 810873d

Please sign in to comment.