ussd-data-connect/pkg/data/decode_test.go

44 lines
785 B
Go
Raw Normal View History

2024-12-19 15:23:36 +01:00
package data
import (
"encoding/hex"
"testing"
)
func TestDecodeKey(t *testing.T) {
type want struct {
sessionID string
dataType uint16
}
type args struct {
keyBytesHex string
}
tests := []struct {
name string
args args
want want
}{
{
"blockchain_address",
args{
keyBytesHex: "202b3235343731313030303132330001",
},
want{
sessionID: "+254711000123",
dataType: ACCOUNT_BLOCKCHAIN_ADDRESS,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
keyBytes, err := hex.DecodeString(tt.args.keyBytesHex)
if err != nil {
t.Fatalf("failed to decode hex string: %v", err)
}
dataType, sessionID := DecodeKey(keyBytes)
t.Logf("%s data_type: %d, session_id: %s", tt.name, dataType, sessionID)
})
}
}