Skip to content

Commit 4362ece

Browse files
committed
test: add smoke tests for public API
Minimal external _test package tests so CI + Codecov report a real test run. Tests exercise only the exported surface; internals stay unexposed.
1 parent e37261d commit 4362ece

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

zz_smoke_test.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// SPDX-License-Identifier: AGPL-3.0-or-later
2+
3+
package runtime_test
4+
5+
import (
6+
"testing"
7+
8+
"github.com/TeoSlayer/pilotprotocol/pkg/daemon"
9+
"github.com/pilot-protocol/runtime"
10+
)
11+
12+
// TestPackageCompiles is a no-op test that proves the test binary links
13+
// against the runtime package. If the package fails to build, this test
14+
// fails to compile, which is the load-bearing assertion.
15+
func TestPackageCompiles(t *testing.T) {
16+
t.Log("package runtime compiles and links")
17+
}
18+
19+
// TestNewRuntime exercises the runtime.New constructor with a zero-value
20+
// daemon Config. We deliberately do not call StartPlugins — that requires
21+
// a fully wired daemon (registry, sockets, identity). Construction is
22+
// enough to flush out import-cycle or interface-mismatch regressions in
23+
// the composition root.
24+
func TestNewRuntime(t *testing.T) {
25+
d := daemon.New(daemon.Config{})
26+
if d == nil {
27+
t.Fatal("daemon.New returned nil")
28+
}
29+
30+
r := runtime.New(d)
31+
if r == nil {
32+
t.Fatal("runtime.New returned nil")
33+
}
34+
35+
if got := r.Daemon(); got != d {
36+
t.Fatalf("Runtime.Daemon() = %p, want %p", got, d)
37+
}
38+
}
39+
40+
// TestNewHandshakeRuntime exercises the handshake.Runtime adapter
41+
// constructor. The returned value satisfies the handshake.Runtime
42+
// interface — that's enforced at compile time inside the package via
43+
// a `var _ handshake.Runtime = ...` guard — so this test just verifies
44+
// the constructor returns a non-nil adapter from public callers.
45+
func TestNewHandshakeRuntime(t *testing.T) {
46+
d := daemon.New(daemon.Config{})
47+
hr := runtime.NewHandshakeRuntime(d)
48+
if hr == nil {
49+
t.Fatal("NewHandshakeRuntime returned nil")
50+
}
51+
}
52+
53+
// TestNewPolicyRuntime exercises the policy.Runtime adapter
54+
// constructor. Same shape as the handshake adapter test.
55+
func TestNewPolicyRuntime(t *testing.T) {
56+
d := daemon.New(daemon.Config{})
57+
pr := runtime.NewPolicyRuntime(d)
58+
if pr == nil {
59+
t.Fatal("NewPolicyRuntime returned nil")
60+
}
61+
}

0 commit comments

Comments
 (0)