Skip to content

Commit

Permalink
chore(deps): 4-4 bump github.com/ViBiOh/httputils/v4 from 4.50.7 to 4…
Browse files Browse the repository at this point in the history
….51.2

Bumps [github.com/ViBiOh/httputils/v4](https://github.com/ViBiOh/httputils) from 4.50.7 to 4.51.2.
- [Release notes](https://github.com/ViBiOh/httputils/releases)
- [Commits](ViBiOh/httputils@v4.50.7...v4.51.2)

---
updated-dependencies:
- dependency-name: github.com/ViBiOh/httputils/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
dependabot[bot] authored and ViBiOh committed Dec 31, 2022
1 parent c23317c commit 0ae535f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
21 changes: 7 additions & 14 deletions pkg/notifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/ViBiOh/flags"
"github.com/ViBiOh/httputils/v4/pkg/breaksync"
"github.com/ViBiOh/httputils/v4/pkg/clock"
"github.com/ViBiOh/httputils/v4/pkg/logger"
"github.com/ViBiOh/ketchup/pkg/model"
"github.com/ViBiOh/ketchup/pkg/semver"
Expand All @@ -19,38 +18,34 @@ import (
"github.com/prometheus/client_golang/prometheus/push"
)

type GetNow func() time.Time

var pageSize = uint(20)

// App of package
type App struct {
repositoryService model.RepositoryService
ketchupService model.KetchupService
userService user.App
mailerApp model.Mailer
helmApp model.HelmProvider

clock clock.Clock

pushURL string
clock GetNow
pushURL string
}

// Config of package
type Config struct {
pushURL *string
}

// Flags adds flags for configuring package
func Flags(fs *flag.FlagSet, prefix string) Config {
return Config{
pushURL: flags.String(fs, prefix, "notifier", "PushUrl", "Pushgateway URL", "", nil),
}
}

// New creates new App from Config
func New(config Config, repositoryService model.RepositoryService, ketchupService model.KetchupService, userService user.App, mailerApp model.Mailer, helmApp model.HelmProvider) App {
return App{
pushURL: strings.TrimSpace(*config.pushURL),

pushURL: strings.TrimSpace(*config.pushURL),
clock: time.Now,
repositoryService: repositoryService,
ketchupService: ketchupService,
userService: userService,
Expand All @@ -59,7 +54,6 @@ func New(config Config, repositoryService model.RepositoryService, ketchupServic
}
}

// Notify users for new ketchup
func (a App) Notify(ctx context.Context) error {
if err := a.repositoryService.Clean(ctx); err != nil {
return fmt.Errorf("clean repository before starting: %w", err)
Expand Down Expand Up @@ -147,7 +141,7 @@ func (a App) getKetchupToNotify(ctx context.Context, releases []model.Release) (

userToNotify := a.syncReleasesByUser(ctx, releases, ketchups)

if a.clock.Now().Weekday() == time.Monday {
if a.clock().Weekday() == time.Monday {
weeklyKetchups, err := a.ketchupService.ListOutdated(ctx)
if err != nil {
return nil, fmt.Errorf("get weekly ketchups: %w", err)
Expand Down Expand Up @@ -283,7 +277,6 @@ func (a App) sendNotification(ctx context.Context, template string, ketchupToNot
return nil
}

// Remind users for new ketchup
func (a App) Remind(ctx context.Context) error {
usersToRemind, err := a.userService.ListReminderUsers(ctx)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/notifier/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"time"

authModel "github.com/ViBiOh/auth/v2/pkg/model"
"github.com/ViBiOh/httputils/v4/pkg/clock"
"github.com/ViBiOh/ketchup/pkg/mocks"
"github.com/ViBiOh/ketchup/pkg/model"
"github.com/ViBiOh/ketchup/pkg/semver"
Expand Down Expand Up @@ -256,7 +255,7 @@ func TestGetKetchupToNotify(t *testing.T) {

instance := App{
ketchupService: mockKetchupService,
clock: clock.New(time.Unix(1609459200, 0)),
clock: func() time.Time { return time.Unix(1609459200, 0) },
}

switch intention {
Expand Down
2 changes: 0 additions & 2 deletions pkg/notifier/releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ func TestGetNewStandardReleases(t *testing.T) {
},
}

pageSize = 20

for intention, testCase := range cases {
intention, testCase := intention, testCase

Expand Down

0 comments on commit 0ae535f

Please sign in to comment.