You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
564 B

  1. package common
  2. import (
  3. "database/sql"
  4. "database/sql/driver"
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestTxIDScannerValue(t *testing.T) {
  9. txid0 := &TxID{}
  10. txid1 := &TxID{}
  11. txid0B := [12]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
  12. txid1B := [12]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  13. copy(txid0[:], txid0B[:])
  14. copy(txid1[:], txid1B[:])
  15. var value driver.Valuer
  16. var scan sql.Scanner
  17. value = txid0
  18. scan = txid1
  19. fromDB, err := value.Value()
  20. assert.NoError(t, err)
  21. assert.NoError(t, scan.Scan(fromDB))
  22. assert.Equal(t, value, scan)
  23. }