2022-05-10 17:47:26 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/spf13/afero"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestIssue156(t *testing.T) {
|
|
|
|
puzzles := NewTestMothballs()
|
|
|
|
state := NewTestState()
|
|
|
|
theme := NewTestTheme()
|
|
|
|
server := NewMothServer(Configuration{}, theme, state, puzzles)
|
|
|
|
|
|
|
|
afero.WriteFile(state, "teams/bloop", []byte("bloop: the team"), 0644)
|
2022-05-17 15:08:40 -06:00
|
|
|
afero.WriteFile(state, "teamids.txt", []byte("bloop"), 0644)
|
2022-05-10 17:47:26 -06:00
|
|
|
state.refresh()
|
|
|
|
|
|
|
|
handler := server.NewHandler("", "bloop")
|
|
|
|
es := handler.ExportState()
|
|
|
|
if _, ok := es.TeamNames["self"]; !ok {
|
2022-05-17 15:08:40 -06:00
|
|
|
t.Log("Team 'bloop' not found in exported state")
|
2022-05-10 17:47:26 -06:00
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
|
|
|
|
err := handler.Register("bloop: the other team")
|
|
|
|
if err != ErrAlreadyRegistered {
|
2022-05-17 15:08:40 -06:00
|
|
|
t.Logf("Expected ErrAlreadyRegistered when registering team, received %s, instead", err)
|
2022-05-10 17:47:26 -06:00
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|