-
Notifications
You must be signed in to change notification settings - Fork 4
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: copy .env file error on Windows os. #9
Changes from all commits
0f72970
c0fc37b
cc6d20c
72e1e08
cb48cbc
85ab3f3
b4fa72d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -3,6 +3,8 @@ package commands | |||||||
import ( | ||||||||
"errors" | ||||||||
"io" | ||||||||
"os" | ||||||||
"path/filepath" | ||||||||
"testing" | ||||||||
|
||||||||
"github.com/goravel/framework/contracts/console" | ||||||||
|
@@ -46,6 +48,7 @@ func TestNewCommand(t *testing.T) { | |||||||
assert.Contains(t, captureOutput, ".env file generated successfully!") | ||||||||
assert.Contains(t, captureOutput, "App key generated successfully!") | ||||||||
assert.True(t, file.Exists("example-app")) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
assert.True(t, file.Exists(filepath.Join("example-app", ".env"))) | ||||||||
|
||||||||
mockContext.On("Argument", 0).Return("example-app").Once() | ||||||||
mockContext.On("OptionBool", "force").Return(false).Once() | ||||||||
|
@@ -56,3 +59,21 @@ func TestNewCommand(t *testing.T) { | |||||||
assert.Nil(t, file.Remove("example-app")) | ||||||||
mockContext.AssertExpectations(t) | ||||||||
} | ||||||||
|
||||||||
func TestCopyFile(t *testing.T) { | ||||||||
newCommand := &NewCommand{} | ||||||||
|
||||||||
tmpDir, err := os.MkdirTemp("", "test-copy-file") | ||||||||
assert.Nil(t, err) | ||||||||
src := filepath.Join(tmpDir, ".env.example") | ||||||||
dst := filepath.Join(tmpDir, ".env") | ||||||||
|
||||||||
// Create a mock .env.example file for testing | ||||||||
err = os.WriteFile(src, []byte("example env"), os.ModePerm) | ||||||||
assert.Nil(t, err) | ||||||||
assert.True(t, file.Exists(src)) | ||||||||
assert.Nil(t, newCommand.copyFile(src, dst)) | ||||||||
assert.True(t, file.Exists(dst)) | ||||||||
assert.Nil(t, os.Remove(src)) | ||||||||
assert.Nil(t, os.Remove(dst)) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure! |
||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test case for this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the unit tests. Please check them out.