Skip to content

Commit

Permalink
feat: add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Jun 11, 2023
1 parent 037b17a commit 8699a98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions event/console/event_make_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,13 @@ func TestEventMakeCommand(t *testing.T) {
err = eventMakeCommand.Handle(mockContext)
assert.Nil(t, err)
assert.True(t, file.Exists("app/events/goravel_event.go"))

mockContext.On("Argument", 0).Return("Goravel/Event").Once()
err = eventMakeCommand.Handle(mockContext)
assert.Nil(t, err)
assert.True(t, file.Exists("app/events/Goravel/event.go"))
assert.True(t, file.Contain("app/events/Goravel/event.go", "package Goravel"))
assert.True(t, file.Contain("app/events/Goravel/event.go", "type Event struct {"))

assert.True(t, file.Remove("app"))
}
8 changes: 8 additions & 0 deletions event/console/listener_make_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,13 @@ func TestListenerMakeCommand(t *testing.T) {
err = listenerMakeCommand.Handle(mockContext)
assert.Nil(t, err)
assert.True(t, file.Exists("app/listeners/goravel_listen.go"))

mockContext.On("Argument", 0).Return("Goravel/Listen").Once()
err = listenerMakeCommand.Handle(mockContext)
assert.Nil(t, err)
assert.True(t, file.Exists("app/listeners/Goravel/listen.go"))
assert.True(t, file.Contain("app/listeners/Goravel/listen.go", "package Goravel"))
assert.True(t, file.Contain("app/listeners/Goravel/listen.go", "type Listen struct {"))

assert.True(t, file.Remove("app"))
}

0 comments on commit 8699a98

Please sign in to comment.