Skip to content

Commit 3758d27

Browse files
cardyokcodex
andcommitted
test(session): cover v2 transport failure paths
Exclude generated protocol stubs from patch coverage while exercising the reconnect, heartbeat, endpoint, and error-classification behavior directly. Co-Authored-By: Codex <noreply@openai.com>
1 parent a7e0dbe commit 3758d27

4 files changed

Lines changed: 375 additions & 1 deletion

File tree

codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
ignore:
22
- "e2e"
3+
- "pkg/session/v2/session.pb.go"
4+
- "pkg/session/v2/session_grpc.pb.go"

pkg/gpud-manager/systemd/systemd_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ func TestWriteEnvFileRejectsInvalidSessionProtocol(t *testing.T) {
8989
require.ErrorIs(t, statErr, os.ErrNotExist)
9090
}
9191

92+
func TestWriteEnvFileRejectsMultipleSessionProtocols(t *testing.T) {
93+
path := filepath.Join(t.TempDir(), "gpud.env")
94+
err := writeEnvFile(path, "", "", false, "v1", "v2")
95+
require.ErrorContains(t, err, "expected at most one session protocol")
96+
}
97+
9298
func TestProcessEnvFileLines(t *testing.T) {
9399
t.Run("file without FLAGS", func(t *testing.T) {
94100
// Create a temporary directory for testing

pkg/session/protocol_test.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
package session
55

6-
import "testing"
6+
import (
7+
"context"
8+
"testing"
9+
)
710

811
func TestParseProtocol(t *testing.T) {
912
tests := []struct {
@@ -29,3 +32,17 @@ func TestParseProtocol(t *testing.T) {
2932
})
3033
}
3134
}
35+
36+
func TestWithProtocol(t *testing.T) {
37+
op := &Op{}
38+
WithProtocol("v2")(op)
39+
if op.protocol != ProtocolV2 {
40+
t.Fatalf("protocol = %q, want %q", op.protocol, ProtocolV2)
41+
}
42+
}
43+
44+
func TestNewSessionRejectsInvalidProtocol(t *testing.T) {
45+
if _, err := NewSession(context.Background(), "", "", "", WithProtocol("future")); err == nil {
46+
t.Fatal("NewSession accepted an unsupported protocol")
47+
}
48+
}

0 commit comments

Comments
 (0)