mysql_store_test.go 684 B

123456789101112131415161718192021222324252627282930
  1. package mysql_store
  2. import (
  3. "encoding/json"
  4. "hash/crc32"
  5. "testing"
  6. )
  7. func TestGenerateMysqlConf(t *testing.T) {
  8. var conf []MySqlConf
  9. conf = append(conf, MySqlConf{
  10. User: "root",
  11. Password: "root",
  12. HostName: "localhost",
  13. Port: 3306,
  14. DataBase: "seaweedfs",
  15. })
  16. body, err := json.Marshal(conf)
  17. if err != nil {
  18. t.Errorf("json encoding err %s", err.Error())
  19. }
  20. t.Logf("json output is %s", string(body))
  21. }
  22. func TestCRC32FullPathName(t *testing.T) {
  23. fullPathName := "/prod-bucket/law632191483895612493300-signed.pdf"
  24. hash_value := crc32.ChecksumIEEE([]byte(fullPathName))
  25. table_postfix := int(hash_value) % 1024
  26. t.Logf("table postfix %d", table_postfix)
  27. }