chore: 并入 iotlcm-bot 历史到 bot/(原提交 31dbc1d)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:00 +08:00
36 changed files with 3006 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
package notify
import (
"os"
"path/filepath"
"reflect"
"testing"
)
func TestRunFilesSelectsOnlyTopLevelRunJSON(t *testing.T) {
root := t.TempDir()
for _, name := range []string{
"run-abc.json",
"run-full-id.json",
"action-abc.json",
"sim-status-legacy.json",
"run-temp.json.tmp",
} {
if err := os.WriteFile(filepath.Join(root, name), []byte("{}"), 0o600); err != nil {
t.Fatal(err)
}
}
nested := filepath.Join(root, "2026", "09")
if err := os.MkdirAll(nested, 0o700); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(nested, "run-nested.json"), []byte("{}"), 0o600); err != nil {
t.Fatal(err)
}
svc := Service{archiveDir: root}
got, err := svc.runFiles()
if err != nil {
t.Fatal(err)
}
want := []string{filepath.Join(root, "run-abc.json"), filepath.Join(root, "run-full-id.json")}
if !reflect.DeepEqual(got, want) {
t.Fatalf("runFiles() = %#v, want %#v", got, want)
}
}