Beispiel #1
0
func TestEverything(t *testing.T) {
	go server.Run()
	time.Sleep(time.Second * 2)
	paths := []string{
		"sandbox/client1/",
		"sandbox/client2/",
	}
	ignores := make(map[string]bool)
	for _, value := range paths {
		err := boxtools.CleanTestFolder(value, ignores, true)
		if err != nil {
			panic("Could not delete folder contents")
		}
		go func(value string) {
			cmd := exec.Command(
				"go",
				"run",
				"client/client.go",
				value)
			cmd.Stdout = os.Stdout
			cmd.Stderr = os.Stderr
			cmd.Run()
		}(value)
	}
	select {}
}
Beispiel #2
0
func TestStartWatcher(t *testing.T) {
	_, err := startWatcher("/billybob")
	if err == nil {
		t.Log("startWatcher must fail on invalid directory")
		t.FailNow()
	}

	ch, err := startWatcher(sandboxDir)
	if err != nil {
		t.Log("startWatcher didn't work on a valid directory")
		t.FailNow()
	}

	if reflect.ValueOf(ch).Kind() != reflect.Chan {
		t.Log("Return value from startWatcher must be a channel")
		t.FailNow()
	}
	go boxtools.SimulateFilesystemChanges(sandboxDir, 10, 5, 0)
	for i := 0; i < 18; i++ {
		fmt.Println(<-ch)
		fmt.Println(i)

	}
	ignores := make(map[string]bool)
	ignores[".Gobox"] = true
	abspath, err := filepath.Abs(sandboxDir)
	if err != nil {
		t.Log("Could not clean up properly")
		t.FailNow()
	}
	err = boxtools.CleanTestFolder(abspath, ignores, true)
	if err != nil {
		t.Log(err.Error())
		t.FailNow()
	}
	return
}