github.com/Financial-Times/publish-availability-monitor@v1.12.0/feeds/feedFactory_test.go (about) 1 package feeds 2 3 import ( 4 "net/url" 5 "testing" 6 7 "github.com/Financial-Times/go-logger/v2" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestNewPullFeed(t *testing.T) { 12 baseURL, _ := url.Parse("http://www.example.org/") 13 log := logger.NewUPPLogger("test", "PANIC") 14 15 actual := NewNotificationsFeed("notifications", *baseURL, 10, 10, "expectedUser", "expectedPwd", "", log) 16 assert.IsType(t, (*NotificationsPullFeed)(nil), actual, "expected a NotificationsPullFeed") 17 18 npf := actual.(*NotificationsPullFeed) 19 assert.Equal(t, "expectedUser", npf.username) 20 assert.Equal(t, "expectedPwd", npf.password) 21 } 22 23 func TestNewPushFeed(t *testing.T) { 24 baseURL, _ := url.Parse("http://www.example.org/") 25 log := logger.NewUPPLogger("test", "PANIC") 26 27 actual := NewNotificationsFeed("notifications-push", *baseURL, 10, 10, "expectedUser", "expectedPwd", "expectedApiKey", log) 28 assert.IsType(t, (*NotificationsPushFeed)(nil), actual, "expected a NotificationsPushFeed") 29 30 npf := actual.(*NotificationsPushFeed) 31 assert.Equal(t, "expectedApiKey", npf.apiKey) 32 assert.Equal(t, "expectedUser", npf.username) 33 assert.Equal(t, "expectedPwd", npf.password) 34 }