mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-08 04:55:55 +08:00
parent
f0a472bc3c
commit
4716d79a7e
9
.github/workflows/golint.yml
vendored
9
.github/workflows/golint.yml
vendored
@ -9,6 +9,15 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup Go environment
|
||||||
|
uses: actions/setup-go@v2.1.3
|
||||||
|
with:
|
||||||
|
go-version: 1.16
|
||||||
|
|
||||||
|
- name: Tests
|
||||||
|
run: |
|
||||||
|
run: go test $(go list ./...)
|
||||||
|
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
with:
|
with:
|
||||||
|
9
.github/workflows/suggester.yml
vendored
9
.github/workflows/suggester.yml
vendored
@ -9,6 +9,15 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup Go environment
|
||||||
|
uses: actions/setup-go@v2.1.3
|
||||||
|
with:
|
||||||
|
go-version: 1.16
|
||||||
|
|
||||||
|
- name: Tests
|
||||||
|
run: |
|
||||||
|
run: go test $(go list ./...)
|
||||||
|
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
with:
|
with:
|
||||||
|
27
global/all_test.go
Normal file
27
global/all_test.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package global
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestVersionNameCompare(t *testing.T) {
|
||||||
|
var tests = [...]struct {
|
||||||
|
current string
|
||||||
|
remote string
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{"v0.9.29-fix2", "v0.9.29-fix2", false},
|
||||||
|
{"v0.9.29-fix1", "v0.9.29-fix2", true},
|
||||||
|
{"v0.9.29-fix2", "v0.9.29-fix1", false},
|
||||||
|
{"v0.9.29-fix2", "v0.9.30", true},
|
||||||
|
{"v1.0.0-beta1", "v0.9.40-fix5", false}, // issue #877
|
||||||
|
}
|
||||||
|
for i := 0; i < len(tests); i++ {
|
||||||
|
t.Run("test case "+strconv.Itoa(i), func(t *testing.T) {
|
||||||
|
assert.Equal(t, tests[i].expected, VersionNameCompare(tests[i].current, tests[i].remote))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -79,8 +79,8 @@ func VersionNameCompare(current, remote string) bool {
|
|||||||
for i := 0; i < int(math.Min(float64(len(cur)), float64(len(re)))); i++ {
|
for i := 0; i < int(math.Min(float64(len(cur)), float64(len(re)))); i++ {
|
||||||
curSub, _ := strconv.Atoi(cur[i][0])
|
curSub, _ := strconv.Atoi(cur[i][0])
|
||||||
reSub, _ := strconv.Atoi(re[i][0])
|
reSub, _ := strconv.Atoi(re[i][0])
|
||||||
if curSub < reSub {
|
if curSub != reSub {
|
||||||
return true
|
return curSub < reSub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len(cur) < len(re)
|
return len(cur) < len(re)
|
||||||
|
1
go.mod
1
go.mod
@ -19,6 +19,7 @@ require (
|
|||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
|
||||||
|
github.com/stretchr/testify v1.7.0 // indirect
|
||||||
github.com/syndtr/goleveldb v1.0.0
|
github.com/syndtr/goleveldb v1.0.0
|
||||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
|
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
|
||||||
github.com/tidwall/gjson v1.7.5
|
github.com/tidwall/gjson v1.7.5
|
||||||
|
1
go.sum
1
go.sum
@ -110,6 +110,7 @@ github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic
|
|||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user