Skip to content

Commit

Permalink
test: fixed tests related to style lint changes
Browse files Browse the repository at this point in the history
  • Loading branch information
achannarasappa committed Feb 21, 2022
1 parent bcc4b85 commit ddcc4da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func readConfig(fs afero.Fs, configPathOption string) (c.Config, error) {
configPath, err := getConfigPath(fs, configPathOption)

if err != nil {
return config, err
return config, nil //nolint:nilerr
}
handle, err := fs.Open(configPath)

Expand Down
15 changes: 9 additions & 6 deletions internal/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"io/ioutil"
"os"
"strconv"
"strings"

"github.com/mitchellh/go-homedir"
Expand Down Expand Up @@ -100,7 +101,7 @@ var _ = Describe("Cli", func() {
output := getStdout(func() {
Run(inputStartFn)(&cobra.Command{}, []string{})
})
Expect(output).To(Equal("Unable to start UI: ui error\n"))
Expect(output).To(Equal("unable to start UI: ui error\n"))
Expect(fnIsCalled).To(Equal(true))
})
})
Expand Down Expand Up @@ -253,14 +254,16 @@ var _ = Describe("Cli", func() {
AssertionCtx: g.MatchFields(g.IgnoreExtras, g.Fields{
"Groups": g.MatchAllElementsWithIndex(g.IndexIdentity, g.Elements{
"0": g.MatchFields(g.IgnoreExtras, g.Fields{
"SymbolsBySource": g.MatchAllElementsWithIndex(g.IndexIdentity, g.Elements{
"SymbolsBySource": g.MatchAllElements(func(element interface{}) string {
return strconv.FormatInt(int64(element.(c.AssetGroupSymbolsBySource).Source), 10)
}, g.Elements{
"0": g.MatchFields(g.IgnoreExtras, g.Fields{
"Symbols": g.MatchAllElementsWithIndex(g.IndexIdentity, g.Elements{
"0": Equal("TSLA"),
}),
"Source": Equal(c.QuoteSourceYahoo),
}),
"1": g.MatchFields(g.IgnoreExtras, g.Fields{
"2": g.MatchFields(g.IgnoreExtras, g.Fields{
"Symbols": g.MatchAllElementsWithIndex(g.IndexIdentity, g.Elements{
"0": Equal("ethereum"),
"1": Equal("solana"),
Expand Down Expand Up @@ -503,7 +506,7 @@ var _ = Describe("Cli", func() {
outputCtx, outputErr := GetContext(depLocal, cli.Options{}, inputConfigPath)

Expect(outputCtx.Config).To(Equal(c.Config{}))
Expect(outputErr).To(MatchError("Invalid config: open .config-file-that-does-not-exist.yaml: file does not exist"))
Expect(outputErr).To(MatchError("invalid config: open .config-file-that-does-not-exist.yaml: file does not exist"))
})
})

Expand All @@ -514,7 +517,7 @@ var _ = Describe("Cli", func() {
outputCtx, outputErr := GetContext(depLocal, cli.Options{}, inputConfigPath)

Expect(outputCtx.Config).To(Equal(c.Config{}))
Expect(outputErr).To(MatchError("Invalid config: yaml: unmarshal errors:\n line 2: cannot unmarshal !!str `NOK` into []string"))
Expect(outputErr).To(MatchError("invalid config: yaml: unmarshal errors:\n line 2: cannot unmarshal !!str `NOK` into []string"))

})
})
Expand All @@ -536,7 +539,7 @@ var _ = Describe("Cli", func() {
It("should return an error", func() {
options.Watchlist = ""
outputErr := Validate(&ctx, &options, nil)(&cobra.Command{}, []string{})
Expect(outputErr).To(MatchError("Invalid config: No watchlist provided"))
Expect(outputErr).To(MatchError("invalid config: No watchlist provided"))
})

When("a nil error reference is passed in from Cobra", func() {
Expand Down
2 changes: 1 addition & 1 deletion internal/print/print_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var _ = Describe("Print", func() {
output := getStdout(func() {
print.Run(&inputDependencies, &inputContext, &inputOptions)(&cobra.Command{}, []string{})
})
Expect(output).To(Equal("[{\"name\":\"Alphabet Inc.\",\"symbol\":\"GOOG\",\"price\":2838.42,\"value\":28384.2,\"cost\":10000,\"quantity\":10,\"weight\":96.99689027099068},{\"name\":\"Roblox Corporation\",\"symbol\":\"RBLX\",\"price\":87.88,\"value\":878.8,\"cost\":500,\"quantity\":10,\"weight\":3.0031097290093287}]\n"))
Expect(output).To(Equal("[{\"name\":\"Alphabet Inc.\",\"symbol\":\"GOOG\",\"price\":\"2838.420000\",\"value\":\"28384.200000\",\"cost\":\"10000.000000\",\"quantity\":\"10.000000\",\"weight\":\"96.996890\"},{\"name\":\"Roblox Corporation\",\"symbol\":\"RBLX\",\"price\":\"87.880000\",\"value\":\"878.800000\",\"cost\":\"500.000000\",\"quantity\":\"10.000000\",\"weight\":\"3.003110\"}]\n"))
})

When("the format option is set to csv", func() {
Expand Down

0 comments on commit ddcc4da

Please sign in to comment.