Skip to content

Commit

Permalink
Rename manual sync to selective sync
Browse files Browse the repository at this point in the history
  • Loading branch information
lovelaze committed Mar 5, 2025
1 parent c4213cb commit 2f6104f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This project is not a part of the [official Pi-hole project](https://github.com/

## Features
- **Full sync**: Use Pi-hole Teleporter for full synchronization.
- **Manual sync**: Selective feature synchronization.
- **Selective sync**: Selective feature synchronization.
- **Cron schedule**: Run on chron schedule.

## Installation
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (suite *testSuite) Test_FullSync_SSL() {
require.NoError(suite.T(), err)
}

func (suite *testSuite) Test_ManualSync() {
func (suite *testSuite) Test_SelectiveSync() {
suite.T().Setenv("PRIMARY", suite.ph1.EnvString(false))
suite.T().Setenv("REPLICAS", suite.ph2.EnvString(false))
suite.T().Setenv("FULL_SYNC", "false")
Expand Down
22 changes: 11 additions & 11 deletions internal/mocks/sync/Target.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (service *Service) doSync(t sync.Target) (err error) {
if service.conf.Sync.FullSync {
err = t.FullSync(service.conf.Sync)
} else {
err = t.ManualSync(service.conf.Sync)
err = t.SelectiveSync(service.conf.Sync)
}

if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestRun_full(t *testing.T) {
target.AssertCalled(t, "FullSync", conf.Sync)
}

func TestRun_manual(t *testing.T) {
func TestRun_selective(t *testing.T) {
conf := config.Config{
Primary: model.PiHole{},
Replicas: []model.PiHole{},
Expand All @@ -43,7 +43,7 @@ func TestRun_manual(t *testing.T) {
}

target := syncmock.NewTarget(t)
target.On("ManualSync", conf.Sync).Return(nil)
target.On("SelectiveSync", conf.Sync).Return(nil)

service := Service{
target: target,
Expand All @@ -53,5 +53,5 @@ func TestRun_manual(t *testing.T) {
err := service.Run()
require.NoError(t, err)

target.AssertCalled(t, "ManualSync", conf.Sync)
target.AssertCalled(t, "SelectiveSync", conf.Sync)
}
2 changes: 1 addition & 1 deletion internal/sync/manual.go → internal/sync/selective.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/rs/zerolog/log"
)

func (target *target) ManualSync(syncConf *config.Sync) error {
func (target *target) SelectiveSync(syncConf *config.Sync) error {
log.Info().Str("mode", "selective").Int("replicas", len(target.Replicas)).Msg("Running sync")

if err := target.authenticate(); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
)

func TestTarget_ManualSync(t *testing.T) {
func TestTarget_SelectiveSync(t *testing.T) {
primary := piholemock.NewClient(t)
replica := piholemock.NewClient(t)

Expand Down Expand Up @@ -56,6 +56,6 @@ func TestTarget_ManualSync(t *testing.T) {
primary.EXPECT().DeleteSession().Once().Return(nil)
replica.EXPECT().DeleteSession().Once().Return(nil)

err := target.ManualSync(&settings)
err := target.SelectiveSync(&settings)
require.NoError(t, err)
}
2 changes: 1 addition & 1 deletion internal/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type Target interface {
FullSync(sync *config.Sync) error
ManualSync(sync *config.Sync) error
SelectiveSync(sync *config.Sync) error
}

type target struct {
Expand Down

0 comments on commit 2f6104f

Please sign in to comment.