You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudreve/pkg/conf/version_test.go

28 lines
568 B

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)
}