-
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.
fix: resolve param expansion <no value> errors
- Loading branch information
Neil Hemming
committed
Jul 21, 2021
1 parent
95ffccd
commit 191a931
Showing
8 changed files
with
210 additions
and
41 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
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,82 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/nehemming/cirocket/pkg/buildinfo" | ||
) | ||
|
||
func TestNewCli(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
cli := newCli(ctx) | ||
|
||
if cli.rootCmd == nil { | ||
t.Error("no root cmd") | ||
} | ||
|
||
if cli.ctx != ctx { | ||
t.Error("wrong context") | ||
} | ||
} | ||
|
||
func TestNewCliRootCmd(t *testing.T) { | ||
ctx := buildinfo.NewInfo("1.0", "", "", "", "").NewContext(context.Background()) | ||
|
||
cli := newCli(ctx) | ||
|
||
rootCmd := cli.rootCmd | ||
|
||
if rootCmd.Args == nil { | ||
t.Error("Args") | ||
} | ||
if rootCmd.SilenceErrors == false { | ||
t.Error("SilenceErrors") | ||
} | ||
|
||
if rootCmd.Version == "" { | ||
t.Error("Version") | ||
} | ||
} | ||
|
||
func TestInitConfigBlankAppNameErrors(t *testing.T) { | ||
cli := newCli(context.Background()) | ||
|
||
if cli.initError != nil { | ||
t.Error("pre init error") | ||
} | ||
|
||
cli.appName = "" | ||
|
||
cli.initConfig() | ||
if cli.initError == nil { | ||
t.Error("expected error") | ||
} | ||
} | ||
|
||
func TestInitConfig(t *testing.T) { | ||
cli := newCli(context.Background()) | ||
|
||
if cli.initError != nil { | ||
t.Error("pre init error") | ||
} | ||
|
||
cli.appName = "notknown" | ||
|
||
cli.initConfig() | ||
if cli.initError == nil || !strings.HasPrefix(cli.initError.Error(), "Config File \".notknown.yml\"") { | ||
t.Error("unexpected", cli.initError) | ||
} | ||
} | ||
|
||
func TestRun(t *testing.T) { | ||
ctx := buildinfo.NewInfo("1.0", "", "", "", "").NewContext(context.Background()) | ||
|
||
exitCode := runWithArgs(ctx, []string{"--version"}) | ||
|
||
if exitCode != ExitCodeSuccess { | ||
t.Error("unexpected exit code", exitCode) | ||
} | ||
} |
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
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
Oops, something went wrong.