mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 14:26:36 +08:00
1e19d8114a
- Split shared monolithic consts into bot, push, and errs with typed sentinel errors - Restructure model layer into distinct bot and push subdomains - Refactor DAO layer to enforce single-owner principle and remove cross-table raw SQL queries - Decompose 1150+ line service/push.go into push_channel, push_event, push_trigger, push_worker, and push_template - Clean up controller layer with generic request handlers and parameter validation in controller/base.go - Streamline plugin.go to core Cordis lifecycle orchestration and remove re-export bloat - Verify all unit tests, race tests, Cordis architecture rules, and Swagger generation pass cleanly
28 lines
701 B
Go
28 lines
701 B
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package service_test
|
|
|
|
import (
|
|
"Wavelet/plugins/domain/msg_gateway/consts"
|
|
"Wavelet/plugins/domain/msg_gateway/service"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGenerateCode_AlphabetAndLength(t *testing.T) {
|
|
code, err := service.GenerateCode()
|
|
require.NoError(t, err)
|
|
assert.Len(t, code, consts.CodeLength)
|
|
for _, r := range code {
|
|
assert.Contains(t, consts.CodeAlphabet, string(r))
|
|
}
|
|
}
|
|
|
|
func TestNormalizeAndFormat(t *testing.T) {
|
|
assert.Equal(t, "ABCDEFGH", service.NormalizeCode("ab-cd-ef-gh"))
|
|
assert.Equal(t, "ABCD-EFGH", service.FormatCode("ABCDEFGH"))
|
|
}
|