|
@@ -38,6 +38,44 @@ func TestReadDropfileFail(t *testing.T) {
|
|
|
d.ReadDropfile("This_File_Will_Not_Be_Found")
|
|
|
}
|
|
|
|
|
|
+func TestLogfileFailure(t *testing.T) {
|
|
|
+ tmpFile, err := ioutil.TempFile(os.TempDir(), "test-")
|
|
|
+ if err != nil {
|
|
|
+ panic("Cannot create temporary file")
|
|
|
+ }
|
|
|
+
|
|
|
+ defer func() {
|
|
|
+ if r := recover(); r == nil {
|
|
|
+ t.Error("Init did not panic on logfile error.")
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ // Remember to clean up the file afterwards
|
|
|
+ defer os.Remove(tmpFile.Name())
|
|
|
+
|
|
|
+ // This test should fail before we even need sockets
|
|
|
+
|
|
|
+ var fd int = 0
|
|
|
+
|
|
|
+ // Create door32.sys file
|
|
|
+ dfc := DropfileConfig{2, fd, 1800, "Test BBSID", 1701, "Real Username", "Handle", 880, 28, 0, 13}
|
|
|
+
|
|
|
+ tmpFile.WriteString(fmt.Sprintf("%d\n%d\n%d\n%s\n%d\n%s\n%s\n%d\n%d\n%d\n%d\n",
|
|
|
+ dfc.Comm_type, dfc.Comm_handle, dfc.Baudrate, dfc.BBSID, dfc.User_number, dfc.Real_name, dfc.Handle,
|
|
|
+ dfc.Security_level, dfc.Time_left, dfc.Emulation, dfc.Node))
|
|
|
+ tmpFile.Close()
|
|
|
+
|
|
|
+ d := Door{}
|
|
|
+
|
|
|
+ // If I call d.Init() more then once flag complains about flag redefined.
|
|
|
+ // Reset flags
|
|
|
+ flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
|
|
|
+ // preset commandline args so door can init
|
|
|
+ os.Args = []string{"door", "-d", tmpFile.Name()}
|
|
|
+ d.Init("/badname-test")
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
func TestReadDropFile(t *testing.T) {
|
|
|
tmpFile, err := ioutil.TempFile(os.TempDir(), "test-")
|
|
|
if err != nil {
|