Skip to content

Commit

Permalink
test(command): ensure faked lang matches the default (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Apr 4, 2023
1 parent 792d68e commit dd3c99f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
repos:
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
- id: golangci-lint
# - repo: https://github.com/tekwizely/pre-commit-golang
# rev: v1.0.0-rc.1
# hooks:
# - id: golangci-lint

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"--fast"
],
"cSpell.words": [
"cubiest",
"extendio",
"graffico",
"jibberjabber",
"sidewalk"
]
}
4 changes: 2 additions & 2 deletions src/app/command/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (b *Bootstrap) Execute(initialise func(LocaleDetector) []string) {
}

type configureOptions struct {
confileFile *string
configFile *string
}

type ConfigureOptionFn func(*configureOptions)
Expand All @@ -96,7 +96,7 @@ func configure(options ...ConfigureOptionFn) {
var configFile string

o := configureOptions{
confileFile: &configFile,
configFile: &configFile,
}
for _, fo := range options {
fo(&o)
Expand Down
8 changes: 4 additions & 4 deletions src/app/command/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"golang.org/x/text/language"
)

type USFake struct {
type DetectorStub struct {
}

func (j *USFake) Scan() language.Tag {
return language.AmericanEnglish
func (j *DetectorStub) Scan() language.Tag {
return language.BritishEnglish
}

var _ = Describe("Bootstrap", Ordered, func() {
Expand All @@ -36,7 +36,7 @@ var _ = Describe("Bootstrap", Ordered, func() {
Context("widget command", func() {
It("🧪 should: invoke without error", func() {
bootstrap := command.Bootstrap{
Detector: &USFake{},
Detector: &DetectorStub{},
}
bootstrap.Execute(func(detector command.LocaleDetector) []string {

Expand Down
2 changes: 1 addition & 1 deletion src/app/command/root-cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var _ = Describe("RootCmd", Ordered, func() {

It("🧪 should: execute", func() {
Expect(command.Execute(func(o *command.ExecutionOptions) {
o.Detector = &USFake{}
o.Detector = &DetectorStub{}
o.From = from
})).Error().To(BeNil())
})
Expand Down
10 changes: 7 additions & 3 deletions src/app/command/widget-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func buildWidgetCommand(container *assistant.CobraContainer) *cobra.Command {
//
if rps := container.MustGetParamSet(RootPsName).(*assistant.ParamSet[RootParameterSet]); rps.Native.ConfigFile != "" { //nolint:errcheck // is Must call
configure(func(co *configureOptions) {
*co.confileFile = rps.Native.ConfigFile
*co.configFile = rps.Native.ConfigFile
})
}

Expand Down Expand Up @@ -126,7 +126,9 @@ func buildWidgetCommand(container *assistant.CobraContainer) *cobra.Command {
if paramSet.Native.OutputFormatEnumInfo.En(value) == XMLFormatEn {
return nil
}
return fmt.Errorf("only xml format is currently supported, other formats available in future release")
return fmt.Errorf(
"only xml format is currently supported, other formats available in future release",
)
},
)

Expand All @@ -147,7 +149,9 @@ func buildWidgetCommand(container *assistant.CobraContainer) *cobra.Command {
return nil
}

return fmt.Errorf("pattern is invalid, missing mandatory capture groups ('date' or 'd', 'm', and 'y')")
return fmt.Errorf(
"pattern is invalid, missing mandatory capture groups ('date' or 'd', 'm', and 'y')",
)
},
)

Expand Down

0 comments on commit dd3c99f

Please sign in to comment.