Skip to content

Commit

Permalink
add more pedal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BK1031 committed Apr 17, 2024
1 parent 0300381 commit 362a7c3
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions ingest/service/gr24/pedal_service_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,55 @@
package gr24service

import (
gr24model "ingest/model/gr24"
"ingest/utils"
"testing"
)

func TestPedalSubscribe(t *testing.T) {
utils.InitializeLogger()
t.Run("Pedal Subscribe Test 1", func(t *testing.T) {
// Arrange
pedalCallbacks = []func(pedal gr24model.Pedal){}
// Act
PedalSubscribe(func(pedal gr24model.Pedal) {})
// Assert
if len(pedalCallbacks) != 1 {
t.Errorf("Expected pedalCallbacks length to be 1, got %v", len(pedalCallbacks))
}
})
t.Run("Pedal Subscribe Test 2", func(t *testing.T) {
// Arrange
pedalCallbacks = []func(pedal gr24model.Pedal){}
// Act
PedalSubscribe(func(pedal gr24model.Pedal) {})
PedalSubscribe(func(pedal gr24model.Pedal) {})
// Assert
if len(pedalCallbacks) != 2 {
t.Errorf("Expected pedalCallbacks length to be 2, got %v", len(pedalCallbacks))
}
})
}

func TestPedalNotify(t *testing.T) {
utils.InitializeLogger()
t.Run("Pedal Notify Test 1", func(t *testing.T) {
// Arrange
pedalCallbacks = []func(pedal gr24model.Pedal){}
pedal := gr24model.Pedal{
ID: "test",
}
// Act
PedalSubscribe(func(pedal gr24model.Pedal) {
// Assert
if pedal.ID != "test" {
t.Error("Expected pedal.ID to not be empty")
}
})
pedalNotify(pedal)
})
}

func TestParsePedal(t *testing.T) {
utils.InitializeLogger()
t.Run("Pedal Test 1", func(t *testing.T) {
Expand Down

0 comments on commit 362a7c3

Please sign in to comment.