1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-16 04:24:56 +02:00
thalos/transport/redis_common/key_test.go

35 lines
1 KiB
Go

package redis_common
import (
"testing"
"eosio-ship-trace-reader/transport"
)
func TestKey_String(t *testing.T) {
type fields struct {
NS Namespace
Channel transport.Channel
}
tests := []struct {
name string
fields fields
want string
}{
{"Empty", fields{NS: Namespace{}, Channel: transport.Channel{}}, "ship::0000000000000000000000000000000000000000000000000000000000000000::"},
{"Transactions", fields{NS: Namespace{ChainID: "id"}, Channel: transport.Channel{"transactions"}}, "ship::id::transactions"},
{"Nested", fields{NS: Namespace{ChainID: "id"}, Channel: transport.Channel{"one.two"}}, "ship::id::one.two"},
{"Action", fields{NS: Namespace{ChainID: "id"}, Channel: transport.Action{Contract: "mycontract"}.Channel()}, "ship::id::actions/contract/mycontract"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
k := Key{
NS: tt.fields.NS,
Channel: tt.fields.Channel,
}
if got := k.String(); got != tt.want {
t.Errorf("Key.String() = %v, want %v", got, tt.want)
}
})
}
}