Path: blob/main/component/loki/source/gcplog/internal/gcplogtarget/push_translation_test.go
4096 views
package gcplogtarget12import (3"testing"4)56func TestConvertToLokiCompatibleLabel(t *testing.T) {7type args struct {8label string9}10tests := []struct {11name string12args args13want string14}{15{16name: "Google timestamp label attribute name",17args: args{18label: "logging.googleapis.com/timestamp",19},20want: "logging_googleapis_com_timestamp",21},22{23name: "Label attribute name with multiple non-underscore characters",24args: args{25label: "logging.googleapis.com/Crazy-label",26},27want: "logging_googleapis_com_crazy_label",28},29{30name: "Label attribute name in CamelCase converted into SnakeCase",31args: args{32label: "logging.googleapis.com/CrazyLabel",33},34want: "logging_googleapis_com_crazy_label",35},36}37for _, tt := range tests {38t.Run(tt.name, func(t *testing.T) {39if got := convertToLokiCompatibleLabel(tt.args.label); got != tt.want {40t.Errorf("convertToLokiCompatibleLabel() = %v, want %v", got, tt.want)41}42})43}44}454647