Exemplo n.º 1
0
func TestMain(m *testing.M) {
	tempdir, err := ioutil.TempDir("", "test_")
	if err != nil {
		log.Fatal(err)
	}

	os.Mkdir(path.Join(tempdir, "logs"), 0777)
	storage.Initialize(tempdir)
	user = storage.NewUser("uuid")
	channelStore = storage.NewChannelStore()

	code := m.Run()

	os.RemoveAll(tempdir)
	os.Exit(code)
}
Exemplo n.º 2
0
	"github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
	"github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/spf13/cobra"
	"github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/spf13/viper"

	"github.com/khlieng/name_pending/assets"
	"github.com/khlieng/name_pending/server"
	"github.com/khlieng/name_pending/storage"
)

var (
	rootCmd = &cobra.Command{
		Use:   "name_pending",
		Short: "Web-based IRC client in Go.",
		Run: func(cmd *cobra.Command, args []string) {
			storage.Initialize(appDir)
			server.Run(viper.GetInt("port"))
		},

		PersistentPreRun: func(cmd *cobra.Command, args []string) {
			appDir = viper.GetString("dir")

			os.Mkdir(appDir, 0777)
			os.Mkdir(path.Join(appDir, "logs"), 0777)

			initConfig()

			viper.SetConfigName("config")
			viper.AddConfigPath(appDir)
			viper.ReadInConfig()
		},