mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:21:10 +02:00
Replace 21 separate NestJS Matrix bot processes (~2.1 GB RAM, ~4.2 GB Docker images) with a single Go binary using plugin architecture (8.6 MB binary, ~30 MB RAM). New services: - services/mana-matrix-bot/ — Go Matrix bot with 21 plugins (mautrix-go, Redis sessions) - services/mana-api-gateway-go/ — Go API gateway (rate limiting, API keys, credit billing) Deleted: - 21 services/matrix-*-bot/ directories - packages/bot-services/ and packages/matrix-bot-common/ - Legacy deploy scripts and CI build jobs Updated: - docker-compose.macmini.yml: new Go services, legacy bots removed - CI/CD: change detection + build jobs for Go services - Root package.json: new dev:matrix, build:matrix, test:matrix scripts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
71 lines
1.2 KiB
Go
71 lines
1.2 KiB
Go
package clock
|
|
|
|
import "testing"
|
|
|
|
func TestParseDuration(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
want int // seconds
|
|
}{
|
|
{"25m", 25 * 60},
|
|
{"25", 25 * 60},
|
|
{"1h", 3600},
|
|
{"1h30m", 5400},
|
|
{"2h", 7200},
|
|
{"90", 90 * 60},
|
|
{"1h0m", 3600},
|
|
{"0", 0},
|
|
{"abc", 0},
|
|
{"", 0},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
got := parseDuration(tt.input)
|
|
if got != tt.want {
|
|
t.Errorf("parseDuration(%q) = %d, want %d", tt.input, got, tt.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestParseAlarmTime(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
want string
|
|
}{
|
|
{"07:30", "07:30"},
|
|
{"7:30", "7:30"},
|
|
{"14:00", "14:00"},
|
|
{"7 uhr 30", "7:30"},
|
|
{"7 30", "7:30"},
|
|
{"7", "7:00"},
|
|
{"abc", ""},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
got := parseAlarmTime(tt.input)
|
|
if got != tt.want {
|
|
t.Errorf("parseAlarmTime(%q) = %q, want %q", tt.input, got, tt.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestFormatDuration(t *testing.T) {
|
|
tests := []struct {
|
|
seconds int
|
|
want string
|
|
}{
|
|
{0, "0:00"},
|
|
{65, "1:05"},
|
|
{3600, "1:00:00"},
|
|
{3661, "1:01:01"},
|
|
{1500, "25:00"},
|
|
{-5, "0:00"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
got := formatDuration(tt.seconds)
|
|
if got != tt.want {
|
|
t.Errorf("formatDuration(%d) = %q, want %q", tt.seconds, got, tt.want)
|
|
}
|
|
}
|
|
}
|