mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 10:17:17 +08:00
fix: test
This commit is contained in:
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
- name: Set up environment
|
||||
run: |
|
||||
cp panel-example.conf .env
|
||||
echo "DB_FILE=database/panel.db" >> .env
|
||||
echo "DB_FILE=$(pwd)/database/panel.db" >> .env
|
||||
go run . artisan key:generate
|
||||
go run . artisan migrate
|
||||
- name: Run tests
|
||||
|
||||
@@ -44,7 +44,7 @@ unit_test:
|
||||
- apt-get update
|
||||
- apt-get install -y curl jq
|
||||
- cp panel-example.conf .env
|
||||
- echo "DB_FILE=database/panel.db" >> .env
|
||||
- echo "DB_FILE=$(pwd)/database/panel.db" >> .env
|
||||
- go run . artisan key:generate
|
||||
- go run . artisan migrate
|
||||
- go test -v -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
type SettingTestSuite struct {
|
||||
suite.Suite
|
||||
setting Setting
|
||||
}
|
||||
|
||||
func TestSettingTestSuite(t *testing.T) {
|
||||
suite.Run(t, &SettingTestSuite{
|
||||
setting: NewSettingImpl(),
|
||||
})
|
||||
}
|
||||
|
||||
func (s *SettingTestSuite) SetupTest() {
|
||||
|
||||
}
|
||||
|
||||
func (s *SettingTestSuite) TestGet() {
|
||||
/*mockOrm, mockDb, _, _ := mock.Orm()
|
||||
mockOrm.On("Query").Return(mockDb).Twice()
|
||||
mockDb.On("Where", "key", "test").Return(mockDb).Twice()
|
||||
mockDb.On("FirstOrFail", &models.Setting{}).Return(nil).Twice()
|
||||
a := s.setting.Get("test")
|
||||
b := s.setting.Get("test", "test")
|
||||
s.Equal("", a)
|
||||
s.Equal("test", b)*/
|
||||
}
|
||||
|
||||
func (s *SettingTestSuite) TestSet() {
|
||||
/*mockOrm, mockDb, _, _ := mock.Orm()
|
||||
mockOrm.On("Query").Return(mockDb).Once()
|
||||
mockDb.On("UpdateOrCreate", &models.Setting{}, models.Setting{Key: "test"}, models.Setting{Value: "test"}).Return(nil).Once()
|
||||
err := s.setting.Set("test", "test")
|
||||
s.Nil(err)*/
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package feature
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"panel/tests"
|
||||
)
|
||||
|
||||
type ExampleTestSuite struct {
|
||||
suite.Suite
|
||||
tests.TestCase
|
||||
}
|
||||
|
||||
func TestExampleTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(ExampleTestSuite))
|
||||
}
|
||||
|
||||
// SetupTest will run before each test in the suite.
|
||||
func (s *ExampleTestSuite) SetupTest() {
|
||||
}
|
||||
|
||||
// TearDownTest will run after each test in the suite.
|
||||
func (s *ExampleTestSuite) TearDownTest() {
|
||||
}
|
||||
|
||||
func (s *ExampleTestSuite) TestIndex() {
|
||||
s.True(true)
|
||||
}
|
||||
38
tests/setting/setting_test.go
Normal file
38
tests/setting/setting_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"panel/app/services"
|
||||
"panel/tests"
|
||||
)
|
||||
|
||||
type SettingTestSuite struct {
|
||||
suite.Suite
|
||||
tests.TestCase
|
||||
setting services.Setting
|
||||
}
|
||||
|
||||
func TestSettingTestSuite(t *testing.T) {
|
||||
suite.Run(t, &SettingTestSuite{
|
||||
setting: services.NewSettingImpl(),
|
||||
})
|
||||
}
|
||||
|
||||
func (s *SettingTestSuite) SetupTest() {
|
||||
|
||||
}
|
||||
|
||||
func (s *SettingTestSuite) TestGet() {
|
||||
a := s.setting.Get("test")
|
||||
b := s.setting.Get("test", "test")
|
||||
s.Equal("", a)
|
||||
s.Equal("test", b)
|
||||
}
|
||||
|
||||
func (s *SettingTestSuite) TestSet() {
|
||||
err := s.setting.Set("test", "test")
|
||||
s.Nil(err)
|
||||
}
|
||||
@@ -1,19 +1,23 @@
|
||||
package services
|
||||
package user
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"panel/app/services"
|
||||
"panel/tests"
|
||||
)
|
||||
|
||||
type UserTestSuite struct {
|
||||
suite.Suite
|
||||
user User
|
||||
tests.TestCase
|
||||
user services.User
|
||||
}
|
||||
|
||||
func TestUserTestSuite(t *testing.T) {
|
||||
suite.Run(t, &UserTestSuite{
|
||||
user: NewUserImpl(),
|
||||
user: services.NewUserImpl(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -22,13 +26,7 @@ func (s *UserTestSuite) SetupTest() {
|
||||
}
|
||||
|
||||
func (s *UserTestSuite) TestCreate() {
|
||||
/*mockOrm, mockDb, _, _ := mock.Orm()
|
||||
mockOrm.On("Query").Return(mockDb).Once()
|
||||
mockDb.On("Create", &models.User{
|
||||
Username: "haozi",
|
||||
Password: "123456",
|
||||
}).Return(nil).Once()
|
||||
user, err := s.user.Create("haozi", "123456")
|
||||
s.Nil(err)
|
||||
s.Equal("haozi", user.Username)*/
|
||||
s.Equal("haozi", user.Username)
|
||||
}
|
||||
Reference in New Issue
Block a user