func TestReadConfigInvalidPath(t *testing.T) {
	fmt.Println("\n\n>>>>>>>>>>>>>>>>>>> TestReadConfigInvalidPath <<<<<<<<<<<<<<<<<<<<<<<<<<")
	// Load Config
	if err := config.Init("../configxxx.json"); err == nil {
		t.Errorf("Attempting to load an invalid file should have caused an error", err)
	}
	fmt.Println("   (Should have just received a CRIT error 'Failed to open...')")
}
func TestRepeatReadConfig(t *testing.T) {
	fmt.Println("\n\n>>>>>>>>>>>>>>>>>>> TestRepeatReadConfig <<<<<<<<<<<<<<<<<<<<<<<<<<")
	if err := config.Init("../config.json"); err == nil {
		t.Errorf("Duplicate calls to config.Init() should have resulted in a warning")
	}
	fmt.Println("   (Should have just received a WARN error 'Duplicate calls...')")

}
func TestReadConfigInvalidJSON(t *testing.T) {
	fmt.Println("\n\n>>>>>>>>>>>>>>>>>>> TestReadConfigInvalidJSON <<<<<<<<<<<<<<<<<<<<<<<<<<")
	// Load Config
	if err := config.Init("tests/config_faulty.json"); err == nil {
		t.Errorf("Attempting to load a faulty file should have caused an error", err)
	}
	fmt.Println("    (Should have just received a CRIT error 'Invalid JSON...')")
}
func init() {
	if err := config.Init("../config.json"); err != nil {
		fmt.Printf("Error loading config file: %s\n", err)
	}

	if err := data.Init("../data.json"); err != nil {
		fmt.Printf("Error loading config file: %s\n", err)
	}

}
func init() {
	var port int64
	flag.BoolVar(&Debug, "debug", false, "Activate debug prints to the console.  Active if either this or the value in 'config.json' are set.")
	flag.Int64Var(&port, "port", 0, "Port.  If set, this flag will override the value in 'config.json'.")
	flag.Parse()

	logs.Init(Debug)

	if err := config.Init("config.json", port); err != nil {
		log.Error("Error loading config file: %s\n", err)
	}

	if err := data.Init("data.json"); err != nil {
		log.Error("Error loading config file: %s\n", err)
	}
	log.Info("Running on port: %d", config.Port())

	go SignalHandler(make(chan os.Signal, 1))
	fmt.Println("Press Ctrl-C to shutdown...")
}
func TestReadConfig(t *testing.T) {
	fmt.Println("\n\n>>>>>>>>>>>>>>>>>>> TestReadConfig <<<<<<<<<<<<<<<<<<<<<<<<<<")
	// Load Config
	if err := config.Init("../config.json"); err != nil {
		t.Errorf("Error %v occurred when loading the config.", err)
	}
	fmt.Printf("%v", config.C.Display())
	if config.C.Loaded != true {
		t.Errorf("System configuration is not marked as loaded.")
	}

	//  Test Auth()
	ac := "1234567890"
	if a := config.Auth(ac); !a {
		t.Errorf("Auth() failed.")
	}

	ac = "1111"
	if a := config.Auth(ac); a {
		t.Errorf("Auth() passed erroneously for: %q", ac)
	}

}