Skip to content

Commit 5ce7ba6

Browse files
committed
fix(tmdl): handle errors in unit tests
1 parent 0128293 commit 5ce7ba6

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

pkg/tmdl/channel_test.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,16 @@ func TestGetNextFrame(t *testing.T) {
6565

6666
frame1 := &tmdl.TMTransferFrame{}
6767
frame2 := &tmdl.TMTransferFrame{}
68-
vc.AddFrame(frame1)
69-
vc.AddFrame(frame2)
68+
69+
err := vc.AddFrame(frame1)
70+
if err != nil {
71+
t.Errorf("Failed to add frame1: %v", err)
72+
}
73+
74+
err = vc.AddFrame(frame2)
75+
if err != nil {
76+
t.Errorf("Failed to add frame2: %v", err)
77+
}
7078

7179
retrievedFrame, err := vc.GetNextFrame()
7280
if err != nil {
@@ -102,13 +110,19 @@ func TestHasFrames(t *testing.T) {
102110
}
103111

104112
frame := &tmdl.TMTransferFrame{}
105-
vc.AddFrame(frame)
113+
err := vc.AddFrame(frame)
114+
if err != nil {
115+
t.Errorf("Failed to add frame: %v", err)
116+
}
106117

107118
if !vc.HasFrames() {
108119
t.Errorf("Expected HasFrames to be true, got false")
109120
}
110121

111-
vc.GetNextFrame()
122+
_, err = vc.GetNextFrame()
123+
if err != nil {
124+
t.Errorf("Failed to retrieve frame: %v", err)
125+
}
112126

113127
if vc.HasFrames() {
114128
t.Errorf("Expected HasFrames to be false, got true")

pkg/tmdl/mux_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,19 @@ func TestMultiplexerHasPendingFrames(t *testing.T) {
101101
}
102102

103103
frame := &tmdl.TMTransferFrame{}
104-
vc.AddFrame(frame)
104+
err := vc.AddFrame(frame)
105+
if err != nil {
106+
t.Errorf("Failed to add frame: %v", err)
107+
}
105108

106109
if !mux.HasPendingFrames() {
107110
t.Errorf("Expected HasPendingFrames to be true, got false")
108111
}
109112

110-
mux.GetNextFrame()
113+
_, err = mux.GetNextFrame()
114+
if err != nil {
115+
t.Fatalf("Expected no error, got %v", err)
116+
}
111117

112118
if mux.HasPendingFrames() {
113119
t.Errorf("Expected HasPendingFrames to be false, got true")

0 commit comments

Comments
 (0)