pomerium/internal/telemetry/metrics/storage_test.go
bobby f837c92741
dev: update linter (#1728)
- 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>
2020-12-30 09:02:57 -08:00

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)
})
}
}