feat: notification provider (#8)
All checks were successful
CD / test (push) Successful in 48s
CD / Build and push (push) Successful in 3m48s

Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
This commit was merged in pull request #8.
This commit is contained in:
2024-08-11 11:52:51 +02:00
committed by t.behrendt
parent b8bdcaa35e
commit 7bb1e9ca08
11 changed files with 304 additions and 31 deletions

View File

@@ -43,6 +43,14 @@ func (m *MockDNSProviderImpl) UpdateRecord(tld string, subdomain string, ip net.
}, nil
}
type MockedNotificationProvider struct{}
type MockedNotificationProviderImpl struct{}
func (m *MockedNotificationProviderImpl) SendNotification(title string, message string) error {
return nil
}
func TestDetectAndApplyChanges(t *testing.T) {
t.Run("with changes", testDetectAndApplyChangesWithChanges())
t.Run("without changes", testDetectAndApplyChangesWithoutChanges())
@@ -55,15 +63,16 @@ func testDetectAndApplyChangesWithChanges() func(t *testing.T) {
}, &MockDNSProviderImpl{
GetRecordIpResponse: "127.0.0.2",
UpdateRecordIpResponse: "127.0.0.1",
}, []config.DomainConfig{
{
TLD: "example.com",
Subdomains: []string{
"test",
"@",
}, &MockedNotificationProviderImpl{},
[]config.DomainConfig{
{
TLD: "example.com",
Subdomains: []string{
"test",
"@",
},
},
},
})
})
numberUpdated, err := changeDetector.DetectAndApplyChanges()
if err != nil {
@@ -83,15 +92,16 @@ func testDetectAndApplyChangesWithoutChanges() func(t *testing.T) {
}, &MockDNSProviderImpl{
GetRecordIpResponse: "127.0.0.1",
UpdateRecordIpResponse: "127.0.0.1",
}, []config.DomainConfig{
{
TLD: "example.com",
Subdomains: []string{
"test",
"@",
}, &MockedNotificationProviderImpl{},
[]config.DomainConfig{
{
TLD: "example.com",
Subdomains: []string{
"test",
"@",
},
},
},
})
})
numberUpdated, err := changeDetector.DetectAndApplyChanges()
if err != nil {