Use base32 encoded UUID to reduce address size
This commit is contained in:
parent
3f5e2c6dd4
commit
849bdb53c5
9 changed files with 188 additions and 41 deletions
|
|
@ -25,6 +25,7 @@ import (
|
|||
"time"
|
||||
|
||||
"git.happydns.org/happyDeliver/internal/api"
|
||||
"git.happydns.org/happyDeliver/internal/utils"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
|
|
@ -96,8 +97,8 @@ func (r *ReportGenerator) GenerateReport(testID uuid.UUID, results *AnalysisResu
|
|||
now := time.Now()
|
||||
|
||||
report := &api.Report{
|
||||
Id: reportID,
|
||||
TestId: testID,
|
||||
Id: utils.UUIDToBase32(reportID),
|
||||
TestId: utils.UUIDToBase32(testID),
|
||||
Score: results.Score.OverallScore,
|
||||
CreatedAt: now,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import (
|
|||
"time"
|
||||
|
||||
"git.happydns.org/happyDeliver/internal/api"
|
||||
"git.happydns.org/happyDeliver/internal/utils"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
|
|
@ -106,12 +107,14 @@ func TestGenerateReport(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify required fields
|
||||
if report.Id == uuid.Nil {
|
||||
if report.Id == "" {
|
||||
t.Error("Report ID should not be empty")
|
||||
}
|
||||
|
||||
if report.TestId != testID {
|
||||
t.Errorf("TestId = %s, want %s", report.TestId, testID)
|
||||
// Convert testID to base32 for comparison
|
||||
expectedTestID := utils.UUIDToBase32(testID)
|
||||
if report.TestId != expectedTestID {
|
||||
t.Errorf("TestId = %s, want %s", report.TestId, expectedTestID)
|
||||
}
|
||||
|
||||
if report.Score < 0 || report.Score > 10 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue