Esempio n. 1
0
func run() (err error) {
	var (
		o option.Options
	)

	o, err = option.New(os.Args[1:])
	if err != nil {
		return
	}

	err = o.ReadPrivateKey()
	if err != nil {
		return
	}

	err = server.Serve(o)
	if err != nil {
		return
	}

	return
}
Esempio n. 2
0
func TestDefault(t *testing.T) {
	o, err := option.New([]string{
		"-i", "AAAA",
		"-k", "BBBB",
	})
	if err != nil {
		t.Fatal(err)
	}

	if o.GoogleAccessID != "AAAA" {
		t.Error("wrong GoogleAccessID:", o.GoogleAccessID)
	}
	if o.PrivateKeyPath != "BBBB" {
		t.Error("wrong PrivateKeyPath:", o.PrivateKeyPath)
	}
	if o.Port != 80 {
		t.Error("wrong Port:", o.Port)
	}
	if o.Duration != time.Minute {
		t.Error("wrong Duration:", o.Duration)
	}
}
Esempio n. 3
0
func TestUnknown(t *testing.T) {
	_, err := option.New([]string{"-x"})
	if err == nil {
		t.Error("should error with unknown flags")
	}
}