From 3a90b559e14542db334d20880237678149c70d52 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 19 Apr 2017 17:05:00 +0900 Subject: [PATCH] account flag is "-profile" --- cmd/mstdn/main.go | 2 +- cmd/mstdn/main_test.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/mstdn/main.go b/cmd/mstdn/main.go index da9db94..b9fcbf0 100644 --- a/cmd/mstdn/main.go +++ b/cmd/mstdn/main.go @@ -172,7 +172,7 @@ func makeApp() *cli.App { app.Version = "0.0.1" app.Flags = []cli.Flag{ cli.StringFlag{ - Name: "a", + Name: "profile", Usage: "profile name", Value: "", }, diff --git a/cmd/mstdn/main_test.go b/cmd/mstdn/main_test.go index f4fdf04..258cd79 100644 --- a/cmd/mstdn/main_test.go +++ b/cmd/mstdn/main_test.go @@ -2,10 +2,13 @@ package main import ( "encoding/json" + "flag" "io/ioutil" "log" "os" "testing" + + "github.com/urfave/cli" ) func TestReadFileFile(t *testing.T) { @@ -72,7 +75,11 @@ func TestGetConfig(t *testing.T) { os.Setenv("APPDATA", appdata) }() - file, config, err := getConfig() + app := makeApp() + set := flag.NewFlagSet("test", 0) + set.Parse([]string{"mstdn", "-profile", ""}) + c := cli.NewContext(app, set, nil) + file, config, err := getConfig(c) if err != nil { t.Fatal(err) } @@ -97,7 +104,7 @@ func TestGetConfig(t *testing.T) { if err != nil { log.Fatal(err) } - file, config, err = getConfig() + file, config, err = getConfig(c) if err != nil { t.Fatal(err) }