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