Files
iotlcm/internal/config/config_test.go
T
MiFaZhan 5732bf3384 chore: 初始开源发布
iotlcm-bot:独立飞书应用机器人(读取 Worker 终态 Run JSON,渲染并发送全量同步结果卡片)。

- Go module:git.5iot.com/iotlcm/iotlcm-bot → git.5iot.com/iotlcm-public/iotlcm-bot
- 飞书凭据占位:appId/appSecret/chatId → ${FEISHU_APP_ID}/${FEISHU_APP_SECRET}/${FEISHU_CHAT_ID}
- 移除内部资产:CI 触发器
- Dockerfile 改用公共基础镜像(golang:1.25-alpine → scratch)
- README 重写(命令/配置/挂载契约/常见问题),去掉内部环境路径
- 补 Apache-2.0 LICENSE,LF 行尾 + .gitattributes
2026-10-22 16:14:24 +08:00

33 lines
846 B
Go

package config
import (
"os"
"path/filepath"
"testing"
"time"
)
func TestLoadYAML(t *testing.T) {
path := filepath.Join(t.TempDir(), "config.yaml")
body := []byte("environment: preview\narchiveDir: /data/full-sync\nstateDir: /data/state\npollInterval: 5s\nfeishu:\n appId: app-id\n appSecret: secret\n chatId: chat-id\n")
if err := os.WriteFile(path, body, 0o600); err != nil {
t.Fatal(err)
}
cfg, err := Load(path)
if err != nil {
t.Fatal(err)
}
if cfg.PollDuration != 5*time.Second || cfg.Feishu.AppID != "app-id" || cfg.ArchiveDir != "/data/full-sync" {
t.Fatalf("unexpected config: %+v", cfg)
}
if err := cfg.ValidateSend(); err != nil {
t.Fatal(err)
}
}
func TestValidateSendRejectsMissingCredentials(t *testing.T) {
if err := (Config{}).ValidateSend(); err == nil {
t.Fatal("expected validation error")
}
}