account flag is "-profile"

This commit is contained in:
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.Flags = []cli.Flag{
cli.StringFlag{
Name: "a",
Name: "profile",
Usage: "profile name",
Value: "",
},

View File

@ -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)
}