TestLifecycle 测试生命周期
(t *testing.T)
| 280 | |
| 281 | // TestLifecycle 测试生命周期 |
| 282 | func TestLifecycle(t *testing.T) { |
| 283 | deps := createTestDependencies(t) |
| 284 | pool := core.NewPool(&core.PoolOptions{ |
| 285 | Dependencies: deps, |
| 286 | MaxAgents: 5, |
| 287 | }) |
| 288 | |
| 289 | os, err := New(&Options{ |
| 290 | Name: "TestOS", |
| 291 | Port: 8080, |
| 292 | Pool: pool, |
| 293 | }) |
| 294 | if err != nil { |
| 295 | t.Fatalf("Failed to create AsterOS: %v", err) |
| 296 | } |
| 297 | |
| 298 | // 初始状态应该不是运行中 |
| 299 | if os.IsRunning() { |
| 300 | t.Error("AsterOS should not be running initially") |
| 301 | } |
| 302 | |
| 303 | // 关闭未运行的 AsterOS 应该失败 |
| 304 | err = os.Shutdown() |
| 305 | if err == nil { |
| 306 | t.Error("Expected error for shutting down non-running AsterOS") |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | // TestGetters 测试 Getter 方法 |
| 311 | func TestGetters(t *testing.T) { |