feat(deploy): 在线更新 - 新增后台检查、强制备份迁移与失败自动回退
This commit is contained in:
27
backend/internal/hostupdate/version_test.go
Normal file
27
backend/internal/hostupdate/version_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package hostupdate
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCompareVersions(t *testing.T) {
|
||||
tests := []struct {
|
||||
left, right string
|
||||
want int
|
||||
}{
|
||||
{"v1.2.0-preview.2", "v1.2.0-preview.3", -1},
|
||||
{"v1.2.0-preview.10", "v1.2.0-preview.3", 1},
|
||||
{"v1.2.0-preview.3", "v1.2.0", -1},
|
||||
{"v1.2.1", "v1.2.0", 1},
|
||||
{"v1.2.0", "v1.2.0", 0},
|
||||
}
|
||||
for _, test := range tests {
|
||||
got := CompareVersions(test.left, test.right)
|
||||
if got < 0 {
|
||||
got = -1
|
||||
} else if got > 0 {
|
||||
got = 1
|
||||
}
|
||||
if got != test.want {
|
||||
t.Fatalf("CompareVersions(%q, %q)=%d, want %d", test.left, test.right, got, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user