1
0
mirror of https://github.com/volatiletech/authboss.git synced 2024-11-28 08:58:38 +02:00
authboss/html_data_test.go
Aaron L de1c2ed081 Get tests working after latest refactors
- Change changelog format to use keepachangelog standard
- Refactor the config to be made of substructs to help organize all the
  pieces
- Add the new interfaces to the configuration
- Clean up module loading (no unnecessary reflection to create new value)
- Change User interface to have a Get/SetPID not E-mail/Username, this
  way we don't ever have to refer to one or the other, we just always
  assume pid. In the case of Confirm/Recover we'll have to make a GetEmail
  or there won't be a way for us to get the e-mail to send to.
- Delete the xsrf nonsense in the core
2018-02-01 15:42:48 -08:00

54 lines
850 B
Go

package authboss
import "testing"
func TestHTMLData(t *testing.T) {
t.Parallel()
data := NewHTMLData("a", "b").MergeKV("c", "d").Merge(NewHTMLData("e", "f"))
if data["a"].(string) != "b" {
t.Error("A was wrong:", data["a"])
}
if data["c"].(string) != "d" {
t.Error("C was wrong:", data["c"])
}
if data["e"].(string) != "f" {
t.Error("E was wrong:", data["e"])
}
}
func TestHTMLData_Panics(t *testing.T) {
t.Parallel()
nPanics := 0
panicCount := func() {
if r := recover(); r != nil {
nPanics++
}
}
func() {
defer panicCount()
NewHTMLData("hello")
}()
func() {
defer panicCount()
NewHTMLData().MergeKV("hello")
}()
func() {
defer panicCount()
NewHTMLData(5, 6)
}()
func() {
defer panicCount()
NewHTMLData().MergeKV(7, 8)
}()
if nPanics != 4 {
t.Error("They all should have paniced.")
}
}