1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-11-03 02:37:23 -05:00
amfora/cache/redir_test.go
2020-08-06 11:56:36 -04:00

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")
}