account flag is "-profile"

pull/28/head
Yasuhiro Matsumoto 2017-04-19 17:05:00 +09:00
parent 3d010df5fb
commit 3a90b559e1
2 changed files with 10 additions and 3 deletions

View File

@ -172,7 +172,7 @@ func makeApp() *cli.App {
app.Version = "0.0.1" app.Version = "0.0.1"
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "a", Name: "profile",
Usage: "profile name", Usage: "profile name",
Value: "", Value: "",
}, },

View File

@ -2,10 +2,13 @@ package main
import ( import (
"encoding/json" "encoding/json"
"flag"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"testing" "testing"
"github.com/urfave/cli"
) )
func TestReadFileFile(t *testing.T) { func TestReadFileFile(t *testing.T) {
@ -72,7 +75,11 @@ func TestGetConfig(t *testing.T) {
os.Setenv("APPDATA", appdata) 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -97,7 +104,7 @@ func TestGetConfig(t *testing.T) {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
file, config, err = getConfig() file, config, err = getConfig(c)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }