From ec23b9797554e37811218aa3446781b4a92ca3f3 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 17 Oct 2023 20:26:16 +0200 Subject: [PATCH] Fix subscriber logic --- subscription.go | 3 +-- subscription_test.go | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/subscription.go b/subscription.go index 2bc0097..184c331 100644 --- a/subscription.go +++ b/subscription.go @@ -39,8 +39,7 @@ func NewHTTPSubscriber(remoteURL, localFile string, interval time.Duration) (*HT if err != nil { return nil, err } - } - if err != nil { + } else if err != nil { return nil, err } diff --git a/subscription_test.go b/subscription_test.go index a18e462..e3b24ca 100644 --- a/subscription_test.go +++ b/subscription_test.go @@ -66,7 +66,10 @@ func TestHTTPSubscriber(t *testing.T) { localFile := "test-local-file.txt" defer os.Remove(localFile) - subscriber := NewHTTPSubscriber(remoteServer.URL, localFile, 500*time.Millisecond) + subscriber, err := NewHTTPSubscriber(remoteServer.URL, localFile, 500*time.Millisecond) + if err != nil { + t.Fatal(err) + } go subscriber.Subscribe() // Allow some time for subscription to run