mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-09 21:08:11 +02:00
zero/telemetry: calculate DAU and MAU (#4810)
This commit is contained in:
parent
e0ac870442
commit
c4dd965f2d
9 changed files with 485 additions and 0 deletions
29
internal/zero/analytics/storage_test.go
Normal file
29
internal/zero/analytics/storage_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package analytics_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/zero/analytics"
|
||||
)
|
||||
|
||||
func TestStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
now := time.Date(2020, 1, 2, 3, 4, 5, 6, time.UTC)
|
||||
state := &analytics.MetricState{
|
||||
Data: []byte("data"),
|
||||
LastReset: now,
|
||||
}
|
||||
|
||||
pbany := state.ToAny()
|
||||
assert.NotNil(t, pbany)
|
||||
|
||||
var newState analytics.MetricState
|
||||
err := newState.FromAny(pbany)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, state.Data, newState.Data)
|
||||
assert.EqualValues(t, state.LastReset.Truncate(time.Second), newState.LastReset.Truncate(time.Second))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue