mirror of
https://github.com/makew0rld/amfora.git
synced 2025-02-02 15:07:34 -05:00
✅ Added redir cache tests - fixes #65
This commit is contained in:
parent
789e7e23a6
commit
5fbef1e517
7
cache/favicons.go
vendored
7
cache/favicons.go
vendored
@ -1,7 +1,6 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@ -50,9 +49,3 @@ func RemoveFavicon(host string) {
|
||||
delete(favicons, host)
|
||||
favMu.Unlock()
|
||||
}
|
||||
|
||||
func AllFavicons() string {
|
||||
favMu.RLock()
|
||||
defer favMu.RUnlock()
|
||||
return fmt.Sprintf("%v", favicons)
|
||||
}
|
||||
|
24
cache/redir_test.go
vendored
Normal file
24
cache/redir_test.go
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
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")
|
||||
}
|
1
go.sum
1
go.sum
@ -202,6 +202,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
|
||||
github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
|
||||
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
|
Loading…
x
Reference in New Issue
Block a user