mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
- gofumpt everything - fix TLS MinVersion to be at least 1.2 - add octal syntax - remove newlines - fix potential decompression bomb in ecjson - remove implicit memory aliasing in for loops. Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
32 lines
977 B
Go
32 lines
977 B
Go
package metrics
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
"time"
|
|
|
|
"go.opencensus.io/stats/view"
|
|
)
|
|
|
|
func Test_RecordStorageOperation(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
tags *StorageOperationTags
|
|
duration time.Duration
|
|
want string
|
|
}{
|
|
{"success", &StorageOperationTags{Operation: "test", Backend: "testengine"}, time.Millisecond * 5, "{ { {backend testengine}{operation test}{result success}{service databroker} }&{1 5 5 5 0"},
|
|
{"error", &StorageOperationTags{Operation: "failtest", Backend: "failengine", Error: errors.New("failure")}, time.Millisecond * 5, "{ { {backend failengine}{operation failtest}{result error}{service databroker} }&{1 5 5 5 0"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
view.Unregister(StorageViews...)
|
|
view.Register(StorageViews...)
|
|
RecordStorageOperation(context.Background(), tt.tags, tt.duration)
|
|
|
|
testDataRetrieval(StorageOperationDurationView, t, tt.want)
|
|
})
|
|
}
|
|
}
|