From 362a7c35691e8659f9d13189896d44458455147b Mon Sep 17 00:00:00 2001 From: Bharat Kathi Date: Tue, 16 Apr 2024 17:17:50 -0700 Subject: [PATCH] add more pedal tests --- ingest/service/gr24/pedal_service_test.go | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/ingest/service/gr24/pedal_service_test.go b/ingest/service/gr24/pedal_service_test.go index 8020207..251cfac 100644 --- a/ingest/service/gr24/pedal_service_test.go +++ b/ingest/service/gr24/pedal_service_test.go @@ -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) {