parent
9b78357bce
commit
64ef556c2b
|
@ -3,8 +3,6 @@ package tenant
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/influxdb/v2"
|
||||
icontext "github.com/influxdata/influxdb/v2/context"
|
||||
"github.com/influxdata/influxdb/v2/kv"
|
||||
|
@ -122,7 +120,7 @@ func (s *OnboardService) onboardUser(ctx context.Context, req *influxdb.Onboardi
|
|||
OrgID: org.ID,
|
||||
Name: req.Bucket,
|
||||
Type: influxdb.BucketTypeUser,
|
||||
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
|
||||
RetentionPeriod: req.RetentionPeriod,
|
||||
}
|
||||
|
||||
if err := s.service.CreateBucket(ctx, ub); err != nil {
|
||||
|
|
|
@ -2,7 +2,9 @@ package tenant_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/influxdata/influxdb/v2/pkg/testing/assert"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
|
@ -154,3 +156,30 @@ func TestOnboardAuth(t *testing.T) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
func TestOnboardService_RetentionPolicy(t *testing.T) {
|
||||
s, _, _ := NewTestInmemStore(t)
|
||||
storage := tenant.NewStore(s)
|
||||
ten := tenant.NewService(storage)
|
||||
|
||||
// we will need an auth service as well
|
||||
svc := tenant.NewOnboardService(ten, kv.NewService(zaptest.NewLogger(t), s))
|
||||
|
||||
ctx := icontext.SetAuthorizer(context.Background(), &influxdb.Authorization{
|
||||
UserID: 123,
|
||||
})
|
||||
|
||||
retention := 72 * time.Hour
|
||||
onboard, err := svc.OnboardInitialUser(ctx, &influxdb.OnboardingRequest{
|
||||
User: "name",
|
||||
Org: "name",
|
||||
Bucket: "name",
|
||||
RetentionPeriod: retention,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
assert.Equal(t, onboard.Bucket.RetentionPeriod, retention, "Retention policy should pass through")
|
||||
}
|
Loading…
Reference in New Issue