MCPcopy Create free account
hub / github.com/Azure/peerd / TestRun

Function TestRun

cmd/proxy/main_test.go:26–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24}
25
26func TestRun(t *testing.T) {
27 // Use the shared test context
28 ctx := testCtx
29
30 testCases := []struct {
31 name string
32 args *Arguments
33 expectError bool
34 errorMsg string
35 }{
36 {
37 name: "version flag",
38 args: &Arguments{
39 Version: true,
40 LogLevel: "info",
41 },
42 expectError: false,
43 },
44 {
45 name: "server command with valid args",
46 args: &Arguments{
47 Server: &ServerCmd{
48 HttpAddr: "127.0.0.1:5000",
49 HttpsAddr: "127.0.0.1:5000",
50 RouterAddr: "127.0.0.1:5000",
51 PromAddr: "127.0.0.1:5000",
52 PrefetchWorkers: 10,
53 },
54 LogLevel: "info",
55 },
56 expectError: true, // Will fail due to k8s dependencies in real implementation
57 },
58 {
59 name: "no subcommand",
60 args: &Arguments{
61 LogLevel: "info",
62 },
63 expectError: true,
64 errorMsg: "unknown subcommand",
65 },
66 }
67
68 for _, tc := range testCases {
69 t.Run(tc.name, func(t *testing.T) {
70 err := run(ctx, tc.args)
71
72 if tc.expectError {
73 if err == nil {
74 t.Error("Expected error but got none")
75 } else if tc.errorMsg != "" && !strings.Contains(err.Error(), tc.errorMsg) {
76 t.Errorf("Expected error to contain %q, got %q", tc.errorMsg, err.Error())
77 }
78 } else {
79 if err != nil {
80 t.Errorf("Expected no error, got %v", err)
81 }
82 }
83 })

Callers

nothing calls this directly

Calls 1

runFunction · 0.70

Tested by

no test coverage detected