Debian Codegraph @

server/backend/types_test.go

raw
1 package backend
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/require"
7 )
8
9 func TestID(t *testing.T) {
10 var v ID
11
12 // We can set the ID from a string.
13 require.NoError(t, v.FromString("AQIDBA=="))
14
15 // We can get the ID as a string.
16 require.Equal(t, "AQIDBA==", v.String())
17
18 // We can get the ID as bytes.
19 require.Equal(t, []byte{1, 2, 3, 4}, v.Bytes())
20
21 // The ID is correct.
22 require.Equal(t, ID(0x01020304), v)
23 }