mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Test: migration modifications
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"github.com/HFO4/cloudreve/pkg/util"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -12,10 +13,12 @@ func TestInitPanic(t *testing.T) {
|
||||
asserts := assert.New(t)
|
||||
|
||||
// 日志路径不存在时
|
||||
asserts.Panics(func() {
|
||||
asserts.NotPanics(func() {
|
||||
Init("not/exist/path")
|
||||
})
|
||||
|
||||
asserts.True(util.Exists("conf.ini"))
|
||||
|
||||
}
|
||||
|
||||
// TestInitDelimiterNotFound 日志路径存在但 Key 格式错误时
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWriteVersionLock(t *testing.T) {
|
||||
asserts := assert.New(t)
|
||||
|
||||
// 清理残余文件
|
||||
if _, err := os.Stat("version.lock"); !os.IsNotExist(err) {
|
||||
err = os.Remove("version.lock")
|
||||
asserts.NoError(err)
|
||||
}
|
||||
|
||||
err := WriteVersionLock()
|
||||
defer func() { err = os.Remove("version.lock") }()
|
||||
writtenVersion, err := ioutil.ReadFile("version.lock")
|
||||
|
||||
// 写入的版本应与当前版本相同
|
||||
asserts.NoError(err)
|
||||
asserts.Equal(string(writtenVersion), BackendVersion)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user