Skip to content
This repository was archived by the owner on Mar 27, 2021. It is now read-only.

Commit ca7fb4b

Browse files
committed
fixed creepy tests
1 parent 767c294 commit ca7fb4b

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

commands/configure.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import (
77
"gopkg.in/ini.v1"
88
)
99

10-
type CmdConfigure struct {
10+
type ConfigureCommand struct {
1111
Alias string `short:"a" long:"alias" description:"role alias" required:"true"`
1212
Arn string `short:"r" long:"role" description:"arn role" required:"true"`
1313
File string `short:"f" long:"file" description:"alias file" default:"~/.mortadelo/alias"`
1414

1515
filePath string
1616
}
1717

18-
func (c *CmdConfigure) Execute(args []string) error {
18+
func (c *ConfigureCommand) Execute(args []string) error {
1919
c.filePath = expandPath(c.File)
2020

2121
err := c.createHome()
@@ -31,7 +31,7 @@ func (c *CmdConfigure) Execute(args []string) error {
3131
return nil
3232
}
3333

34-
func (c *CmdConfigure) createHome() error {
34+
func (c *ConfigureCommand) createHome() error {
3535
path := filepath.Dir(c.filePath)
3636
_, err := os.Stat(path)
3737

@@ -47,7 +47,7 @@ func (c *CmdConfigure) createHome() error {
4747
return nil
4848
}
4949

50-
func (c *CmdConfigure) setAlias() error {
50+
func (c *ConfigureCommand) setAlias() error {
5151
cfg, err := ini.LooseLoad(c.filePath)
5252

5353
if err != nil {

commands/configure_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ const (
1313
testAliasFile = "/tmp/alias_tests"
1414
)
1515

16-
func TestCmdConfigure(t *testing.T) {
17-
cmd := &CmdConfigure{
16+
func TestConfigureCommand(t *testing.T) {
17+
cmd := &ConfigureCommand{
1818
Alias: testAlias,
1919
Arn: testArn,
20+
File: testAliasFile,
2021
}
2122

22-
cmd.setupNewAlias(testAliasFile)
23+
cmd.filePath = testAliasFile
24+
cmd.setAlias()
2325

2426
cfg, _ := ini.LooseLoad(testAliasFile)
2527
alias, _ := cfg.GetSection(testAlias)
2628

2729
if alias.Name() != testAlias {
28-
t.Fatalf("Expected %s, got %s", testAlias, alias.Name)
30+
t.Fatalf("Expected %s, got %s", testAlias, alias.Name())
2931
}
3032

3133
arn, _ := alias.GetKey("arn")

mortadelo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func main() {
1212
parser := flags.NewNamedParser("mortadelo", flags.Default)
1313
parser.AddCommand("assume", "assume role", "", &commands.AssumeCommand{})
1414
parser.AddCommand("clean", "clean generated files", "", &commands.CleanCommand{})
15-
parser.AddCommand("configure", "configure roles alias file", "", &commands.CmdConfigure{})
15+
parser.AddCommand("configure", "configure roles alias file", "", &commands.ConfigureCommand{})
1616

1717
_, err := parser.Parse()
1818
if err != nil {

0 commit comments

Comments
 (0)