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.

redis_test.go 865B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package nosql
  4. import (
  5. "testing"
  6. )
  7. func TestToRedisURI(t *testing.T) {
  8. tests := []struct {
  9. name string
  10. connection string
  11. want string
  12. }{
  13. {
  14. name: "old_default",
  15. connection: "addrs=127.0.0.1:6379 db=0",
  16. want: "redis://127.0.0.1:6379/0",
  17. },
  18. {
  19. name: "old_macaron_session_default",
  20. connection: "network=tcp,addr=127.0.0.1:6379,password=macaron,db=0,pool_size=100,idle_timeout=180",
  21. want: "redis://:macaron@127.0.0.1:6379/0?idle_timeout=180s&pool_size=100",
  22. },
  23. }
  24. for _, tt := range tests {
  25. t.Run(tt.name, func(t *testing.T) {
  26. if got := ToRedisURI(tt.connection); got == nil || got.String() != tt.want {
  27. t.Errorf(`ToRedisURI(%q) = %s, want %s`, tt.connection, got.String(), tt.want)
  28. }
  29. })
  30. }
  31. }