feat: activity log backend foundation
This commit is contained in:
1 parent
8907bb49fe
commit
50b1649965
74 files changed
+5949
-239
No files matched your search
@@ -17,7 +17,11 @@ import (
|
||||
|
||||
func newSettingsRouter(userRepo *mockUserRepo, token *jwtauth.JWTAuth, version string) *chi.Mux {
|
||||
getUserUseCase := useCases.NewGetUserUseCase(userRepo)
|
||||
settingsHandler := settings.NewHandler(useCases.NewGetSettingsUseCase(version))
|
||||
settingsHandler := settings.NewHandler(
|
||||
useCases.NewGetSettingsUseCase(version),
|
||||
useCases.NewGetActivityRetentionUseCase(newActivitySettingsFake()),
|
||||
useCases.NewUpdateActivityRetentionUseCase(newActivitySettingsFake(), discardRecorder),
|
||||
)
|
||||
|
||||
r := chi.NewRouter()
|
||||
r.Route("/v1/settings", func(r chi.Router) {
|
||||
@@ -30,6 +34,10 @@ func newSettingsRouter(userRepo *mockUserRepo, token *jwtauth.JWTAuth, version s
|
||||
return r
|
||||
}
|
||||
|
||||
func settingsBody(version string) string {
|
||||
return `{"version":"` + version + `","activity_retention_days":90,"activity_last_cleanup_at":null,"activity_last_cleanup_removed":0}`
|
||||
}
|
||||
|
||||
func TestSettingsHttp(t *testing.T) {
|
||||
validator.InitValidator()
|
||||
|
||||
@@ -46,7 +54,7 @@ func TestSettingsHttp(t *testing.T) {
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected status 200, got %d: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
if rec.Body.String() != `{"version":"`+version+`"}` {
|
||||
if rec.Body.String() != settingsBody(version) {
|
||||
t.Errorf("unexpected body: %q", rec.Body.String())
|
||||
}
|
||||
})
|
||||
@@ -65,7 +73,7 @@ func TestSettingsHttp(t *testing.T) {
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected status 200, got %d: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
if rec.Body.String() != `{"version":"v2.2.0-beta"}` {
|
||||
if rec.Body.String() != settingsBody("v2.2.0-beta") {
|
||||
t.Errorf("unexpected body: %q", rec.Body.String())
|
||||
}
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user