MCPcopy Create free account
hub / github.com/astercloud/aster / TestOptionsValidation

Function TestOptionsValidation

pkg/asteros/asteros_test.go:444–479  ·  view source on GitHub ↗

TestOptionsValidation 测试配置验证

(t *testing.T)

Source from the content-addressed store, hash-verified

442
443// TestOptionsValidation 测试配置验证
444func TestOptionsValidation(t *testing.T) {
445 // 测试 nil Pool
446 opts := &Options{}
447 err := opts.Validate()
448 if err == nil {
449 t.Error("Expected error for nil pool")
450 }
451
452 // 测试无效端口
453 deps := createTestDependencies(t)
454 pool := core.NewPool(&core.PoolOptions{
455 Dependencies: deps,
456 MaxAgents: 5,
457 })
458
459 opts = &Options{
460 Name: "TestOS",
461 Port: 70000, // 无效端口
462 Pool: pool,
463 }
464 err = opts.Validate()
465 if err == nil {
466 t.Error("Expected error for invalid port")
467 }
468
469 // 测试有效配置
470 opts = &Options{
471 Name: "TestOS",
472 Port: 8080,
473 Pool: pool,
474 }
475 err = opts.Validate()
476 if err != nil {
477 t.Errorf("Valid options should not return error: %v", err)
478 }
479}

Callers

nothing calls this directly

Calls 4

ValidateMethod · 0.95
NewPoolFunction · 0.92
createTestDependenciesFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected