mirror of
https://github.com/makeworld-the-better-one/amfora.git
synced 2024-11-29 23:08:23 +03:00
25 lines
518 B
Go
25 lines
518 B
Go
|
package cache
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestAddRedir(t *testing.T) {
|
||
|
ClearRedirs()
|
||
|
AddRedir("A", "B")
|
||
|
assert.Equal(t, "B", Redirect("A"), "A redirects to B")
|
||
|
|
||
|
// Chain
|
||
|
AddRedir("B", "C")
|
||
|
assert.Equal(t, "C", Redirect("B"), "B redirects to C")
|
||
|
assert.Equal(t, "C", Redirect("A"), "A now redirects to C too")
|
||
|
|
||
|
// Loop
|
||
|
ClearRedirs()
|
||
|
AddRedir("A", "B")
|
||
|
AddRedir("B", "A")
|
||
|
assert.Equal(t, "A", Redirect("B"), "B redirects to A - most recent version of loop is used")
|
||
|
}
|