-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"#53 Introduce support for the follow CLI option"
To make the tailing work again.
- Loading branch information
Showing
5 changed files
with
89 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package command | ||
|
||
import ( | ||
"flag" | ||
"testing" | ||
|
||
"gopkg.in/urfave/cli.v1" | ||
) | ||
|
||
func TestGetCommand(t *testing.T) { | ||
flags := flag.FlagSet{} | ||
flags.Bool("follow", false, "") | ||
commandText := "tail -f -n 10 logs/rest.log" | ||
flags.Parse([]string{"--", "--follow", "dev", commandText}) | ||
app := cli.NewApp() | ||
context := cli.NewContext(app, &flags, nil) | ||
command, extraArgs := getCommand(context, true) | ||
if !command.IsAdHoc() { | ||
t.Errorf("Command name should be ad-hoc, but got %s", command.name) | ||
} | ||
if command.command != commandText { | ||
t.Errorf("Command should be %s, but got %s", commandText, command.command) | ||
} | ||
if extraArgs != "" { | ||
t.Errorf("Extra args should be empty, but got %s", extraArgs) | ||
} | ||
} | ||
|
||
func TestContainsFollow(t *testing.T) { | ||
flags := flag.FlagSet{} | ||
flags.Bool("follow", false, "") | ||
flags.Parse([]string{"--", "--follow", "dev", "tail -f -n 10 logs/rest.log"}) | ||
app := cli.NewApp() | ||
context := cli.NewContext(app, &flags, nil) | ||
follow := ContainsFollow(context) | ||
if !follow { | ||
t.Error("Should contain follow") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters