Skip to content

Commit

Permalink
fix: createdAt should be microseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Apr 7, 2023
1 parent 184ea68 commit 8362f16
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/service/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (s *Admin) GetRejectRulesReportContext(ctx context.Context, req types.Rejec
for i, dropReport := range dropReports {
var createdAt int64
if dropReport.CreatedAt != nil {
createdAt = dropReport.CreatedAt.Unix()
createdAt = dropReport.CreatedAt.UnixMicro()
}

originalReport := dropReport.DropReport
Expand Down
18 changes: 18 additions & 0 deletions test/reject_rule_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package test

import (
"testing"

"github.com/stretchr/testify/assert"
"golang.org/x/mod/semver"
)

func TestRejectRuleSemVer(t *testing.T) {
assert.True(t, semver.IsValid("v4.13.0-beta.4.3.gfe735461"))
assert.True(t, semver.Compare("v4.13.0-beta.4", "v4.13.0-rc.1") < 0, "v4.13.0-beta.4 < v4.13.0-rc.1")
assert.True(t, semver.Compare("v4.13.0-beta.4.3", "v4.13.0-rc.1") < 0, "v4.13.0-beta.4.3 < v4.13.0-rc.1")
assert.True(t, semver.Compare("v4.13.0-beta.4.3.gfe735461", "v4.13.0-rc.1") < 0, "v4.13.0-beta.4.3.gfe735461 < v4.13.0-rc.1")
assert.True(t, semver.Compare("v4.13.0-rc.1", "v4.13.0-rc.1") == 0, "v4.13.0-rc.1 == v4.13.0-rc.1")
assert.True(t, semver.Compare("v4.13.0-rc.1", "v4.13.0-rc.2") < 0, "v4.13.0-rc.1 < v4.13.0-rc.2")
assert.True(t, semver.Compare("v4.13.0-rc.1", "v4.13.0") < 0, "v4.13.0-rc.1 < v4.13.0")
}

0 comments on commit 8362f16

Please sign in to comment.