Skip to content

Commit

Permalink
Merge pull request #10 from OkutaniDaichi0106/feat/add-test-for-group
Browse files Browse the repository at this point in the history
Feat/add test for group
  • Loading branch information
OkutaniDaichi0106 authored Jan 13, 2025
2 parents d8fd007 + 7a92ed6 commit 2dad680
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions internal/message/group_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package message_test

import (
"bytes"
"testing"

"github.com/OkutaniDaichi0106/gomoqt/internal/message"
"github.com/stretchr/testify/assert"
)

func TestGroupMessage(t *testing.T) {
tests := map[string]struct {
testcase message.GroupMessage
want message.GroupMessage
wantErr bool
}{
"valid parameter": {
testcase: message.GroupMessage{
SubscribeID: 1,
GroupSequence: 1,
PublisherPriority: 1,
},
want: message.GroupMessage{
SubscribeID: 1,
GroupSequence: 1,
PublisherPriority: 1,
},
wantErr: false,
},
}

for name, tc := range tests {
t.Run(name, func(t *testing.T) {
t.Parallel()
group := tc.testcase
var buf bytes.Buffer
err := group.Encode(&buf)
if err != nil && !tc.wantErr {
t.Fatalf("unexpected error: %v", err)
}

err = group.Decode(&buf)
if err != nil && !tc.wantErr {
t.Fatalf("unexpected error: %v", err)
}

if err == nil && tc.wantErr {
t.Fatalf("expected error")
}

assert.Equal(t, group, tc.want)

})
}
}

0 comments on commit 2dad680

Please sign in to comment.