mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
perf: correctly align struct fields
This commit is contained in:
parent
0853a527a7
commit
d4b86e63e4
25
src/cache/template.go
vendored
25
src/cache/template.go
vendored
|
@ -7,28 +7,27 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Template struct {
|
type Template struct {
|
||||||
Root bool
|
Env map[string]string
|
||||||
PWD string
|
SegmentsCache maps.Simple
|
||||||
|
Segments *maps.Concurrent
|
||||||
|
Var maps.Simple
|
||||||
|
ShellVersion string
|
||||||
AbsolutePWD string
|
AbsolutePWD string
|
||||||
PSWD string
|
PSWD string
|
||||||
Folder string
|
|
||||||
Shell string
|
|
||||||
ShellVersion string
|
|
||||||
UserName string
|
UserName string
|
||||||
HostName string
|
HostName string
|
||||||
Code int
|
PWD string
|
||||||
Env map[string]string
|
Shell string
|
||||||
Var maps.Simple
|
Folder string
|
||||||
OS string
|
OS string
|
||||||
WSL bool
|
Code int
|
||||||
PromptCount int
|
PromptCount int
|
||||||
SHLVL int
|
SHLVL int
|
||||||
Jobs int
|
Jobs int
|
||||||
Segments *maps.Concurrent
|
|
||||||
SegmentsCache maps.Simple
|
|
||||||
|
|
||||||
Initialized bool
|
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
|
WSL bool
|
||||||
|
Root bool
|
||||||
|
Initialized bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Template) AddSegmentData(key string, value any) {
|
func (t *Template) AddSegmentData(key string, value any) {
|
||||||
|
|
|
@ -62,8 +62,8 @@ func isPaletteKey(colorName Ansi) (Ansi, bool) {
|
||||||
|
|
||||||
// PaletteKeyError records the missing Palette key.
|
// PaletteKeyError records the missing Palette key.
|
||||||
type PaletteKeyError struct {
|
type PaletteKeyError struct {
|
||||||
Key Ansi
|
|
||||||
palette Palette
|
palette Palette
|
||||||
|
Key Ansi
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PaletteKeyError) Error() string {
|
func (p *PaletteKeyError) Error() string {
|
||||||
|
|
|
@ -19,8 +19,8 @@ var (
|
||||||
type TestPaletteRequest struct {
|
type TestPaletteRequest struct {
|
||||||
Case string
|
Case string
|
||||||
Request Ansi
|
Request Ansi
|
||||||
ExpectedError bool
|
|
||||||
Expected Ansi
|
Expected Ansi
|
||||||
|
ExpectedError bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPaletteShouldResolveColorFromTestPalette(t *testing.T) {
|
func TestPaletteShouldResolveColorFromTestPalette(t *testing.T) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package color
|
package color
|
||||||
|
|
||||||
type Palettes struct {
|
type Palettes struct {
|
||||||
Template string `json:"template,omitempty" toml:"template,omitempty"`
|
|
||||||
List map[string]Palette `json:"list,omitempty" toml:"list,omitempty"`
|
List map[string]Palette `json:"list,omitempty" toml:"list,omitempty"`
|
||||||
|
Template string `json:"template,omitempty" toml:"template,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,24 +34,19 @@ const (
|
||||||
|
|
||||||
// Block defines a part of the prompt with optional segments
|
// Block defines a part of the prompt with optional segments
|
||||||
type Block struct {
|
type Block struct {
|
||||||
|
env runtime.Environment
|
||||||
Type BlockType `json:"type,omitempty" toml:"type,omitempty"`
|
Type BlockType `json:"type,omitempty" toml:"type,omitempty"`
|
||||||
Alignment BlockAlignment `json:"alignment,omitempty" toml:"alignment,omitempty"`
|
Alignment BlockAlignment `json:"alignment,omitempty" toml:"alignment,omitempty"`
|
||||||
Segments []*Segment `json:"segments,omitempty" toml:"segments,omitempty"`
|
|
||||||
Newline bool `json:"newline,omitempty" toml:"newline,omitempty"`
|
|
||||||
Filler string `json:"filler,omitempty" toml:"filler,omitempty"`
|
Filler string `json:"filler,omitempty" toml:"filler,omitempty"`
|
||||||
Overflow Overflow `json:"overflow,omitempty" toml:"overflow,omitempty"`
|
Overflow Overflow `json:"overflow,omitempty" toml:"overflow,omitempty"`
|
||||||
|
|
||||||
LeadingDiamond string `json:"leading_diamond,omitempty" toml:"leading_diamond,omitempty"`
|
LeadingDiamond string `json:"leading_diamond,omitempty" toml:"leading_diamond,omitempty"`
|
||||||
TrailingDiamond string `json:"trailing_diamond,omitempty" toml:"trailing_diamond,omitempty"`
|
TrailingDiamond string `json:"trailing_diamond,omitempty" toml:"trailing_diamond,omitempty"`
|
||||||
|
Segments []*Segment `json:"segments,omitempty" toml:"segments,omitempty"`
|
||||||
// Deprecated: keep the logic for legacy purposes
|
|
||||||
HorizontalOffset int `json:"horizontal_offset,omitempty" toml:"horizontal_offset,omitempty"`
|
|
||||||
VerticalOffset int `json:"vertical_offset,omitempty" toml:"vertical_offset,omitempty"`
|
VerticalOffset int `json:"vertical_offset,omitempty" toml:"vertical_offset,omitempty"`
|
||||||
|
HorizontalOffset int `json:"horizontal_offset,omitempty" toml:"horizontal_offset,omitempty"`
|
||||||
MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"`
|
MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"`
|
||||||
MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"`
|
MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"`
|
||||||
|
Newline bool `json:"newline,omitempty" toml:"newline,omitempty"`
|
||||||
env runtime.Environment
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Block) Init(env runtime.Environment) {
|
func (b *Block) Init(env runtime.Environment) {
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
func TestBlockEnabled(t *testing.T) {
|
func TestBlockEnabled(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Expected bool
|
|
||||||
Segments []*Segment
|
|
||||||
Type BlockType
|
Type BlockType
|
||||||
|
Segments []*Segment
|
||||||
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{Case: "line break block", Expected: true, Type: LineBreak},
|
{Case: "line break block", Expected: true, Type: LineBreak},
|
||||||
{Case: "prompt enabled", Expected: true, Type: Prompt, Segments: []*Segment{{Enabled: true}}},
|
{Case: "prompt enabled", Expected: true, Type: Prompt, Segments: []*Segment{{Enabled: true}}},
|
||||||
|
|
|
@ -21,41 +21,36 @@ const (
|
||||||
|
|
||||||
// Config holds all the theme for rendering the prompt
|
// Config holds all the theme for rendering the prompt
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Version int `json:"version" toml:"version"`
|
env runtime.Environment
|
||||||
FinalSpace bool `json:"final_space,omitempty" toml:"final_space,omitempty"`
|
Palette color.Palette `json:"palette,omitempty" toml:"palette,omitempty"`
|
||||||
|
DebugPrompt *Segment `json:"debug_prompt,omitempty" toml:"debug_prompt,omitempty"`
|
||||||
|
Var map[string]any `json:"var,omitempty" toml:"var,omitempty"`
|
||||||
|
Palettes *color.Palettes `json:"palettes,omitempty" toml:"palettes,omitempty"`
|
||||||
|
ValidLine *Segment `json:"valid_line,omitempty" toml:"valid_line,omitempty"`
|
||||||
|
SecondaryPrompt *Segment `json:"secondary_prompt,omitempty" toml:"secondary_prompt,omitempty"`
|
||||||
|
TransientPrompt *Segment `json:"transient_prompt,omitempty" toml:"transient_prompt,omitempty"`
|
||||||
|
ErrorLine *Segment `json:"error_line,omitempty" toml:"error_line,omitempty"`
|
||||||
ConsoleTitleTemplate string `json:"console_title_template,omitempty" toml:"console_title_template,omitempty"`
|
ConsoleTitleTemplate string `json:"console_title_template,omitempty" toml:"console_title_template,omitempty"`
|
||||||
TerminalBackground color.Ansi `json:"terminal_background,omitempty" toml:"terminal_background,omitempty"`
|
Format string `json:"-" toml:"-"`
|
||||||
|
origin string
|
||||||
|
PWD string `json:"pwd,omitempty" toml:"pwd,omitempty"`
|
||||||
AccentColor color.Ansi `json:"accent_color,omitempty" toml:"accent_color,omitempty"`
|
AccentColor color.Ansi `json:"accent_color,omitempty" toml:"accent_color,omitempty"`
|
||||||
|
Output string `json:"-" toml:"-"`
|
||||||
|
TerminalBackground color.Ansi `json:"terminal_background,omitempty" toml:"terminal_background,omitempty"`
|
||||||
|
Cycle color.Cycle `json:"cycle,omitempty" toml:"cycle,omitempty"`
|
||||||
|
ITermFeatures terminal.ITermFeatures `json:"iterm_features,omitempty" toml:"iterm_features,omitempty"`
|
||||||
Blocks []*Block `json:"blocks,omitempty" toml:"blocks,omitempty"`
|
Blocks []*Block `json:"blocks,omitempty" toml:"blocks,omitempty"`
|
||||||
Tooltips []*Segment `json:"tooltips,omitempty" toml:"tooltips,omitempty"`
|
Tooltips []*Segment `json:"tooltips,omitempty" toml:"tooltips,omitempty"`
|
||||||
TransientPrompt *Segment `json:"transient_prompt,omitempty" toml:"transient_prompt,omitempty"`
|
Version int `json:"version" toml:"version"`
|
||||||
ValidLine *Segment `json:"valid_line,omitempty" toml:"valid_line,omitempty"`
|
|
||||||
ErrorLine *Segment `json:"error_line,omitempty" toml:"error_line,omitempty"`
|
|
||||||
SecondaryPrompt *Segment `json:"secondary_prompt,omitempty" toml:"secondary_prompt,omitempty"`
|
|
||||||
DebugPrompt *Segment `json:"debug_prompt,omitempty" toml:"debug_prompt,omitempty"`
|
|
||||||
Palette color.Palette `json:"palette,omitempty" toml:"palette,omitempty"`
|
|
||||||
Palettes *color.Palettes `json:"palettes,omitempty" toml:"palettes,omitempty"`
|
|
||||||
Cycle color.Cycle `json:"cycle,omitempty" toml:"cycle,omitempty"`
|
|
||||||
ShellIntegration bool `json:"shell_integration,omitempty" toml:"shell_integration,omitempty"`
|
|
||||||
PWD string `json:"pwd,omitempty" toml:"pwd,omitempty"`
|
|
||||||
Var map[string]any `json:"var,omitempty" toml:"var,omitempty"`
|
|
||||||
EnableCursorPositioning bool `json:"enable_cursor_positioning,omitempty" toml:"enable_cursor_positioning,omitempty"`
|
|
||||||
PatchPwshBleed bool `json:"patch_pwsh_bleed,omitempty" toml:"patch_pwsh_bleed,omitempty"`
|
|
||||||
DisableNotice bool `json:"disable_notice,omitempty" toml:"disable_notice,omitempty"`
|
DisableNotice bool `json:"disable_notice,omitempty" toml:"disable_notice,omitempty"`
|
||||||
AutoUpgrade bool `json:"auto_upgrade,omitempty" toml:"auto_upgrade,omitempty"`
|
AutoUpgrade bool `json:"auto_upgrade,omitempty" toml:"auto_upgrade,omitempty"`
|
||||||
ITermFeatures terminal.ITermFeatures `json:"iterm_features,omitempty" toml:"iterm_features,omitempty"`
|
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
OSC99 bool `json:"osc99,omitempty" toml:"osc99,omitempty"`
|
OSC99 bool `json:"osc99,omitempty" toml:"osc99,omitempty"`
|
||||||
|
ShellIntegration bool `json:"shell_integration,omitempty" toml:"shell_integration,omitempty"`
|
||||||
Output string `json:"-" toml:"-"`
|
|
||||||
MigrateGlyphs bool `json:"-" toml:"-"`
|
MigrateGlyphs bool `json:"-" toml:"-"`
|
||||||
Format string `json:"-" toml:"-"`
|
PatchPwshBleed bool `json:"patch_pwsh_bleed,omitempty" toml:"patch_pwsh_bleed,omitempty"`
|
||||||
|
EnableCursorPositioning bool `json:"enable_cursor_positioning,omitempty" toml:"enable_cursor_positioning,omitempty"`
|
||||||
origin string
|
|
||||||
// eval bool
|
|
||||||
updated bool
|
updated bool
|
||||||
env runtime.Environment
|
FinalSpace bool `json:"final_space,omitempty" toml:"final_space,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cfg *Config) MakeColors() color.String {
|
func (cfg *Config) MakeColors() color.String {
|
||||||
|
|
|
@ -19,10 +19,10 @@ func TestGetPalette(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
|
||||||
Palettes *color.Palettes
|
Palettes *color.Palettes
|
||||||
Palette color.Palette
|
Palette color.Palette
|
||||||
ExpectedPalette color.Palette
|
ExpectedPalette color.Palette
|
||||||
|
Case string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "match",
|
Case: "match",
|
||||||
|
|
|
@ -20,10 +20,10 @@ const (
|
||||||
|
|
||||||
func TestHasProperty(t *testing.T) {
|
func TestHasProperty(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
|
||||||
Expected bool
|
|
||||||
Property properties.Property
|
|
||||||
Props properties.Map
|
Props properties.Map
|
||||||
|
Case string
|
||||||
|
Property properties.Property
|
||||||
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{Case: "Match", Expected: true, Property: Foo, Props: properties.Map{Foo: "bar"}},
|
{Case: "Match", Expected: true, Property: Foo, Props: properties.Map{Foo: "bar"}},
|
||||||
{Case: "No Match", Expected: false, Property: Foo, Props: properties.Map{Bar: "foo"}},
|
{Case: "No Match", Expected: false, Property: Foo, Props: properties.Map{Bar: "foo"}},
|
||||||
|
@ -40,10 +40,10 @@ func TestHasProperty(t *testing.T) {
|
||||||
|
|
||||||
func TestMigratePropertyValue(t *testing.T) {
|
func TestMigratePropertyValue(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
|
||||||
Expected any
|
Expected any
|
||||||
Property properties.Property
|
|
||||||
Props properties.Map
|
Props properties.Map
|
||||||
|
Case string
|
||||||
|
Property properties.Property
|
||||||
}{
|
}{
|
||||||
{Case: "Match", Expected: "foo", Property: Foo, Props: properties.Map{Foo: "bar"}},
|
{Case: "Match", Expected: "foo", Property: Foo, Props: properties.Map{Foo: "bar"}},
|
||||||
{Case: "No Match", Expected: nil, Property: Foo, Props: properties.Map{Bar: "foo"}},
|
{Case: "No Match", Expected: nil, Property: Foo, Props: properties.Map{Bar: "foo"}},
|
||||||
|
@ -59,11 +59,11 @@ func TestMigratePropertyValue(t *testing.T) {
|
||||||
|
|
||||||
func TestMigratePropertyKey(t *testing.T) {
|
func TestMigratePropertyKey(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
|
||||||
Expected any
|
Expected any
|
||||||
|
Props properties.Map
|
||||||
|
Case string
|
||||||
OldProperty properties.Property
|
OldProperty properties.Property
|
||||||
NewProperty properties.Property
|
NewProperty properties.Property
|
||||||
Props properties.Map
|
|
||||||
}{
|
}{
|
||||||
{Case: "Match", Expected: "bar", OldProperty: Foo, NewProperty: Bar, Props: properties.Map{Foo: "bar"}},
|
{Case: "Match", Expected: "bar", OldProperty: Foo, NewProperty: Bar, Props: properties.Map{Foo: "bar"}},
|
||||||
{Case: "No match", Expected: nil, OldProperty: Foo, NewProperty: Bar, Props: properties.Map{FooBar: "bar"}},
|
{Case: "No match", Expected: nil, OldProperty: Foo, NewProperty: Bar, Props: properties.Map{FooBar: "bar"}},
|
||||||
|
@ -95,10 +95,10 @@ func (m *MockedWriter) Init(_ properties.Properties, _ runtime.Environment) {}
|
||||||
|
|
||||||
func TestIconOverride(t *testing.T) {
|
func TestIconOverride(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Props properties.Map
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
Property properties.Property
|
Property properties.Property
|
||||||
Props properties.Map
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Match",
|
Case: "Match",
|
||||||
|
@ -133,13 +133,13 @@ func TestIconOverride(t *testing.T) {
|
||||||
|
|
||||||
func TestColorMigration(t *testing.T) {
|
func TestColorMigration(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Props properties.Map
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
Property properties.Property
|
Property properties.Property
|
||||||
Template string
|
Template string
|
||||||
Background bool
|
Background bool
|
||||||
NoOverride bool
|
NoOverride bool
|
||||||
Props properties.Map
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Foreground override",
|
Case: "Foreground override",
|
||||||
|
@ -191,10 +191,10 @@ func TestColorMigration(t *testing.T) {
|
||||||
|
|
||||||
func TestSegmentTemplateMigration(t *testing.T) {
|
func TestSegmentTemplateMigration(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Props properties.Map
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
Type SegmentType
|
Type SegmentType
|
||||||
Props properties.Map
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "GIT",
|
Case: "GIT",
|
||||||
|
@ -336,10 +336,10 @@ func TestSegmentTemplateMigration(t *testing.T) {
|
||||||
|
|
||||||
func TestInlineColorOverride(t *testing.T) {
|
func TestInlineColorOverride(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Props properties.Map
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
Property properties.Property
|
Property properties.Property
|
||||||
Props properties.Map
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Match",
|
Case: "Match",
|
||||||
|
@ -374,9 +374,9 @@ func TestInlineColorOverride(t *testing.T) {
|
||||||
|
|
||||||
func TestMigratePreAndPostfix(t *testing.T) {
|
func TestMigratePreAndPostfix(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Props properties.Map
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
Props properties.Map
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Pre and Postfix",
|
Case: "Pre and Postfix",
|
||||||
|
|
|
@ -10,11 +10,11 @@ import (
|
||||||
|
|
||||||
func TestShouldHideForWidth(t *testing.T) {
|
func TestShouldHideForWidth(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Error error
|
||||||
Case string
|
Case string
|
||||||
MinWidth int
|
MinWidth int
|
||||||
MaxWidth int
|
MaxWidth int
|
||||||
Width int
|
Width int
|
||||||
Error error
|
|
||||||
Expected bool
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{Case: "No settings"},
|
{Case: "No settings"},
|
||||||
|
|
|
@ -35,41 +35,37 @@ func (s *SegmentStyle) resolve(env runtime.Environment, context any) SegmentStyl
|
||||||
}
|
}
|
||||||
|
|
||||||
type Segment struct {
|
type Segment struct {
|
||||||
Type SegmentType `json:"type,omitempty" toml:"type,omitempty"`
|
writer SegmentWriter
|
||||||
Tips []string `json:"tips,omitempty" toml:"tips,omitempty"`
|
env runtime.Environment
|
||||||
Style SegmentStyle `json:"style,omitempty" toml:"style,omitempty"`
|
Properties properties.Map `json:"properties,omitempty" toml:"properties,omitempty"`
|
||||||
PowerlineSymbol string `json:"powerline_symbol,omitempty" toml:"powerline_symbol,omitempty"`
|
|
||||||
LeadingPowerlineSymbol string `json:"leading_powerline_symbol,omitempty" toml:"leading_powerline_symbol,omitempty"`
|
LeadingPowerlineSymbol string `json:"leading_powerline_symbol,omitempty" toml:"leading_powerline_symbol,omitempty"`
|
||||||
InvertPowerline bool `json:"invert_powerline,omitempty" toml:"invert_powerline,omitempty"`
|
Background color.Ansi `json:"background" toml:"background"`
|
||||||
ForegroundTemplates template.List `json:"foreground_templates,omitempty" toml:"foreground_templates,omitempty"`
|
Style SegmentStyle `json:"style,omitempty" toml:"style,omitempty"`
|
||||||
BackgroundTemplates template.List `json:"background_templates,omitempty" toml:"background_templates,omitempty"`
|
Text string `json:"-" toml:"-"`
|
||||||
|
name string
|
||||||
LeadingDiamond string `json:"leading_diamond,omitempty" toml:"leading_diamond,omitempty"`
|
LeadingDiamond string `json:"leading_diamond,omitempty" toml:"leading_diamond,omitempty"`
|
||||||
TrailingDiamond string `json:"trailing_diamond,omitempty" toml:"trailing_diamond,omitempty"`
|
TrailingDiamond string `json:"trailing_diamond,omitempty" toml:"trailing_diamond,omitempty"`
|
||||||
Template string `json:"template,omitempty" toml:"template,omitempty"`
|
Template string `json:"template,omitempty" toml:"template,omitempty"`
|
||||||
Templates template.List `json:"templates,omitempty" toml:"templates,omitempty"`
|
Foreground color.Ansi `json:"foreground" toml:"foreground"`
|
||||||
TemplatesLogic template.Logic `json:"templates_logic,omitempty" toml:"templates_logic,omitempty"`
|
TemplatesLogic template.Logic `json:"templates_logic,omitempty" toml:"templates_logic,omitempty"`
|
||||||
Properties properties.Map `json:"properties,omitempty" toml:"properties,omitempty"`
|
PowerlineSymbol string `json:"powerline_symbol,omitempty" toml:"powerline_symbol,omitempty"`
|
||||||
Interactive bool `json:"interactive,omitempty" toml:"interactive,omitempty"`
|
|
||||||
Alias string `json:"alias,omitempty" toml:"alias,omitempty"`
|
|
||||||
MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"`
|
|
||||||
MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"`
|
|
||||||
Filler string `json:"filler,omitempty" toml:"filler,omitempty"`
|
Filler string `json:"filler,omitempty" toml:"filler,omitempty"`
|
||||||
Background color.Ansi `json:"background,omitempty" toml:"background,omitempty"`
|
Alias string `json:"alias,omitempty" toml:"alias,omitempty"`
|
||||||
Foreground color.Ansi `json:"foreground,omitempty" toml:"foreground,omitempty"`
|
Type SegmentType `json:"type,omitempty" toml:"type,omitempty"`
|
||||||
Newline bool `json:"newline,omitempty" toml:"newline,omitempty"`
|
|
||||||
CacheDuration cache.Duration `json:"cache_duration,omitempty" toml:"cache_duration,omitempty"`
|
|
||||||
|
|
||||||
Enabled bool `json:"-" toml:"-"`
|
|
||||||
Text string `json:"-" toml:"-"`
|
|
||||||
|
|
||||||
env runtime.Environment
|
|
||||||
writer SegmentWriter
|
|
||||||
styleCache SegmentStyle
|
styleCache SegmentStyle
|
||||||
name string
|
CacheDuration cache.Duration `json:"cache_duration,omitempty" toml:"cache_duration,omitempty"`
|
||||||
|
BackgroundTemplates template.List `json:"background_templates,omitempty" toml:"background_templates,omitempty"`
|
||||||
// debug info
|
ForegroundTemplates template.List `json:"foreground_templates,omitempty" toml:"foreground_templates,omitempty"`
|
||||||
|
Tips []string `json:"tips,omitempty" toml:"tips,omitempty"`
|
||||||
|
Templates template.List `json:"templates,omitempty" toml:"templates,omitempty"`
|
||||||
|
MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"`
|
||||||
|
MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"`
|
||||||
Duration time.Duration `json:"-" toml:"-"`
|
Duration time.Duration `json:"-" toml:"-"`
|
||||||
NameLength int `json:"-" toml:"-"`
|
NameLength int `json:"-" toml:"-"`
|
||||||
|
Interactive bool `json:"interactive,omitempty" toml:"interactive,omitempty"`
|
||||||
|
Enabled bool `json:"-" toml:"-"`
|
||||||
|
Newline bool `json:"newline,omitempty" toml:"newline,omitempty"`
|
||||||
|
InvertPowerline bool `json:"invert_powerline,omitempty" toml:"invert_powerline,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (segment *Segment) Name() string {
|
func (segment *Segment) Name() string {
|
||||||
|
|
|
@ -94,12 +94,12 @@ func TestShouldIncludeFolder(t *testing.T) {
|
||||||
func TestGetColors(t *testing.T) {
|
func TestGetColors(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Background bool
|
|
||||||
Expected color.Ansi
|
Expected color.Ansi
|
||||||
Templates []string
|
|
||||||
Default color.Ansi
|
Default color.Ansi
|
||||||
Region string
|
Region string
|
||||||
Profile string
|
Profile string
|
||||||
|
Templates []string
|
||||||
|
Background bool
|
||||||
}{
|
}{
|
||||||
{Case: "No template - foreground", Expected: "color", Background: false, Default: "color"},
|
{Case: "No template - foreground", Expected: "color", Background: false, Default: "color"},
|
||||||
{Case: "No template - background", Expected: "color", Background: true, Default: "color"},
|
{Case: "No template - background", Expected: "color", Background: true, Default: "color"},
|
||||||
|
|
|
@ -72,13 +72,13 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type main struct {
|
type main struct {
|
||||||
spinner spinner.Model
|
|
||||||
list *list.Model
|
|
||||||
system bool
|
|
||||||
font string
|
|
||||||
state state
|
|
||||||
err error
|
err error
|
||||||
|
list *list.Model
|
||||||
|
font string
|
||||||
families []string
|
families []string
|
||||||
|
spinner spinner.Model
|
||||||
|
state state
|
||||||
|
system bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *main) buildFontList(nerdFonts []*Asset) {
|
func (m *main) buildFontList(nerdFonts []*Asset) {
|
||||||
|
|
|
@ -109,42 +109,32 @@ func NewRGBColor(ansiColor string) *RGB {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Renderer struct {
|
type Renderer struct {
|
||||||
|
italic font.Face
|
||||||
|
env runtime.Environment
|
||||||
|
bold font.Face
|
||||||
|
regular font.Face
|
||||||
|
defaultForegroundColor *RGB
|
||||||
|
ansiSequenceRegexMap map[string]string
|
||||||
|
foregroundColor *RGB
|
||||||
|
backgroundColor *RGB
|
||||||
|
defaultBackgroundColor *RGB
|
||||||
|
Path string
|
||||||
AnsiString string
|
AnsiString string
|
||||||
Author string
|
Author string
|
||||||
CursorPadding int
|
|
||||||
RPromptOffset int
|
|
||||||
BgColor string
|
|
||||||
|
|
||||||
env runtime.Environment
|
|
||||||
|
|
||||||
Path string
|
|
||||||
|
|
||||||
factor float64
|
|
||||||
|
|
||||||
columns int
|
|
||||||
rows int
|
|
||||||
|
|
||||||
defaultForegroundColor *RGB
|
|
||||||
defaultBackgroundColor *RGB
|
|
||||||
|
|
||||||
shadowBaseColor string
|
shadowBaseColor string
|
||||||
shadowRadius uint8
|
style string
|
||||||
|
BgColor string
|
||||||
shadowOffsetX float64
|
shadowOffsetX float64
|
||||||
shadowOffsetY float64
|
|
||||||
|
|
||||||
padding float64
|
padding float64
|
||||||
margin float64
|
margin float64
|
||||||
|
factor float64
|
||||||
regular font.Face
|
shadowOffsetY float64
|
||||||
bold font.Face
|
rows int
|
||||||
italic font.Face
|
|
||||||
lineSpacing float64
|
lineSpacing float64
|
||||||
|
RPromptOffset int
|
||||||
// canvas switches
|
CursorPadding int
|
||||||
style string
|
columns int
|
||||||
backgroundColor *RGB
|
shadowRadius uint8
|
||||||
foregroundColor *RGB
|
|
||||||
ansiSequenceRegexMap map[string]string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ir *Renderer) Init(env runtime.Environment) error {
|
func (ir *Renderer) Init(env runtime.Environment) error {
|
||||||
|
|
|
@ -15,17 +15,15 @@ import (
|
||||||
var cycle *color.Cycle = &color.Cycle{}
|
var cycle *color.Cycle = &color.Cycle{}
|
||||||
|
|
||||||
type Engine struct {
|
type Engine struct {
|
||||||
Config *config.Config
|
|
||||||
Env runtime.Environment
|
Env runtime.Environment
|
||||||
Plain bool
|
Config *config.Config
|
||||||
|
|
||||||
prompt strings.Builder
|
|
||||||
currentLineLength int
|
|
||||||
rprompt string
|
|
||||||
rpromptLength int
|
|
||||||
|
|
||||||
activeSegment *config.Segment
|
activeSegment *config.Segment
|
||||||
previousActiveSegment *config.Segment
|
previousActiveSegment *config.Segment
|
||||||
|
rprompt string
|
||||||
|
prompt strings.Builder
|
||||||
|
currentLineLength int
|
||||||
|
rpromptLength int
|
||||||
|
Plain bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) write(text string) {
|
func (e *Engine) write(text string) {
|
||||||
|
|
|
@ -17,12 +17,12 @@ import (
|
||||||
|
|
||||||
func TestCanWriteRPrompt(t *testing.T) {
|
func TestCanWriteRPrompt(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
|
||||||
Expected bool
|
|
||||||
TerminalWidth int
|
|
||||||
TerminalWidthError error
|
TerminalWidthError error
|
||||||
|
Case string
|
||||||
|
TerminalWidth int
|
||||||
PromptLength int
|
PromptLength int
|
||||||
RPromptLength int
|
RPromptLength int
|
||||||
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{Case: "Width Error", Expected: false, TerminalWidthError: errors.New("burp")},
|
{Case: "Width Error", Expected: false, TerminalWidthError: errors.New("burp")},
|
||||||
{Case: "Terminal > Prompt enabled", Expected: true, TerminalWidth: 200, PromptLength: 100, RPromptLength: 10},
|
{Case: "Terminal > Prompt enabled", Expected: true, TerminalWidth: 200, PromptLength: 100, RPromptLength: 10},
|
||||||
|
@ -150,12 +150,12 @@ func BenchmarkEngineRenderPalette(b *testing.B) {
|
||||||
func TestGetTitle(t *testing.T) {
|
func TestGetTitle(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Template string
|
Template string
|
||||||
Root bool
|
|
||||||
User string
|
User string
|
||||||
Cwd string
|
Cwd string
|
||||||
PathSeparator string
|
PathSeparator string
|
||||||
ShellName string
|
ShellName string
|
||||||
Expected string
|
Expected string
|
||||||
|
Root bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Template: "{{.Env.USERDOMAIN}} :: {{.PWD}}{{if .Root}} :: Admin{{end}} :: {{.Shell}}",
|
Template: "{{.Env.USERDOMAIN}} :: {{.PWD}}{{if .Root}} :: Admin{{end}} :: {{.Shell}}",
|
||||||
|
@ -220,12 +220,12 @@ func TestGetTitle(t *testing.T) {
|
||||||
func TestGetConsoleTitleIfGethostnameReturnsError(t *testing.T) {
|
func TestGetConsoleTitleIfGethostnameReturnsError(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Template string
|
Template string
|
||||||
Root bool
|
|
||||||
User string
|
User string
|
||||||
Cwd string
|
Cwd string
|
||||||
PathSeparator string
|
PathSeparator string
|
||||||
ShellName string
|
ShellName string
|
||||||
Expected string
|
Expected string
|
||||||
|
Root bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Template: "Not using Host only {{.UserName}} and {{.Shell}}",
|
Template: "Not using Host only {{.UserName}} and {{.Shell}}",
|
||||||
|
|
|
@ -88,9 +88,9 @@ func TestGetBoolInvalidProperty(t *testing.T) {
|
||||||
|
|
||||||
func TestGetFloat64(t *testing.T) {
|
func TestGetFloat64(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Input any
|
||||||
Case string
|
Case string
|
||||||
Expected float64
|
Expected float64
|
||||||
Input any
|
|
||||||
}{
|
}{
|
||||||
{Case: "int", Expected: 1337, Input: 1337},
|
{Case: "int", Expected: 1337, Input: 1337},
|
||||||
{Case: "float64", Expected: 1337, Input: float64(1337)},
|
{Case: "float64", Expected: 1337, Input: float64(1337)},
|
||||||
|
@ -115,11 +115,11 @@ func TestGetFloat64PropertyNotInMap(t *testing.T) {
|
||||||
|
|
||||||
func TestOneOf(t *testing.T) {
|
func TestOneOf(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
|
||||||
Map Map
|
|
||||||
Properties []Property
|
|
||||||
DefaultValue string
|
|
||||||
Expected any
|
Expected any
|
||||||
|
Map Map
|
||||||
|
Case string
|
||||||
|
DefaultValue string
|
||||||
|
Properties []Property
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "one element",
|
Case: "one element",
|
||||||
|
|
|
@ -28,14 +28,14 @@ import (
|
||||||
|
|
||||||
func TestErrors(t *testing.T) {
|
func TestErrors(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
in Errors
|
|
||||||
str string
|
str string
|
||||||
|
in Errors
|
||||||
}{
|
}{
|
||||||
{Errors{nil}, ""},
|
{"", Errors{nil}},
|
||||||
{Errors{errors.New("")}, ""},
|
{"", Errors{errors.New("")}},
|
||||||
{Errors{errors.New("t1")}, "t1"},
|
{"t1", Errors{errors.New("t1")}},
|
||||||
{Errors{errors.New("t2"), errors.New("t3")}, "t2, t3"},
|
{"t2, t3", Errors{errors.New("t2"), errors.New("t3")}},
|
||||||
{Errors{errors.New("t4"), errors.New("t5")}, "t4, t5"},
|
{"t4, t5", Errors{errors.New("t4"), errors.New("t5")}},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, c := range cases {
|
for i, c := range cases {
|
||||||
|
|
|
@ -77,30 +77,31 @@ type Environment interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Flags struct {
|
type Flags struct {
|
||||||
ErrorCode int
|
PSWD string
|
||||||
PipeStatus string
|
PipeStatus string
|
||||||
Config string
|
Config string
|
||||||
Shell string
|
Shell string
|
||||||
ShellVersion string
|
ShellVersion string
|
||||||
PWD string
|
PWD string
|
||||||
PSWD string
|
PromptCount int
|
||||||
ExecutionTime float64
|
ExecutionTime float64
|
||||||
Eval bool
|
JobCount int
|
||||||
StackCount int
|
StackCount int
|
||||||
Migrate bool
|
Column int
|
||||||
TerminalWidth int
|
TerminalWidth int
|
||||||
Strict bool
|
ErrorCode int
|
||||||
Debug bool
|
|
||||||
Plain bool
|
Plain bool
|
||||||
|
Manual bool
|
||||||
|
Debug bool
|
||||||
Primary bool
|
Primary bool
|
||||||
HasTransient bool
|
HasTransient bool
|
||||||
PromptCount int
|
Strict bool
|
||||||
Cleared bool
|
Cleared bool
|
||||||
NoExitCode bool
|
NoExitCode bool
|
||||||
Column int
|
|
||||||
JobCount int
|
|
||||||
SaveCache bool
|
SaveCache bool
|
||||||
Init bool
|
Init bool
|
||||||
|
Migrate bool
|
||||||
|
Eval bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommandError struct {
|
type CommandError struct {
|
||||||
|
@ -129,9 +130,9 @@ const (
|
||||||
|
|
||||||
type WindowsRegistryValue struct {
|
type WindowsRegistryValue struct {
|
||||||
ValueType WindowsRegistryValueType
|
ValueType WindowsRegistryValueType
|
||||||
|
String string
|
||||||
DWord uint64
|
DWord uint64
|
||||||
QWord uint64
|
QWord uint64
|
||||||
String string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type NotImplemented struct{}
|
type NotImplemented struct{}
|
||||||
|
@ -152,9 +153,9 @@ const (
|
||||||
type Connection struct {
|
type Connection struct {
|
||||||
Name string
|
Name string
|
||||||
Type ConnectionType
|
Type ConnectionType
|
||||||
|
SSID string
|
||||||
TransmitRate uint64
|
TransmitRate uint64
|
||||||
ReceiveRate uint64
|
ReceiveRate uint64
|
||||||
SSID string // Wi-Fi only
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Memory struct {
|
type Memory struct {
|
||||||
|
@ -168,12 +169,9 @@ type Memory struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type SystemInfo struct {
|
type SystemInfo struct {
|
||||||
// mem
|
Disks map[string]disk.IOCountersStat
|
||||||
Memory
|
Memory
|
||||||
// load
|
|
||||||
Load1 float64
|
Load1 float64
|
||||||
Load5 float64
|
Load5 float64
|
||||||
Load15 float64
|
Load15 float64
|
||||||
// disk
|
|
||||||
Disks map[string]disk.IOCountersStat
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,14 +31,12 @@ func (a *OAuthError) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
type OAuthRequest struct {
|
type OAuthRequest struct {
|
||||||
Request
|
|
||||||
|
|
||||||
AccessTokenKey string
|
AccessTokenKey string
|
||||||
RefreshTokenKey string
|
RefreshTokenKey string
|
||||||
SegmentName string
|
SegmentName string
|
||||||
|
|
||||||
RefreshToken string
|
RefreshToken string
|
||||||
AccessToken string
|
AccessToken string
|
||||||
|
Request
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OAuthRequest) getAccessToken() (string, error) {
|
func (o *OAuthRequest) getAccessToken() (string, error) {
|
||||||
|
|
|
@ -21,21 +21,19 @@ func TestOauthResult(t *testing.T) {
|
||||||
successData := &data{Hello: "world"}
|
successData := &data{Hello: "world"}
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Error error
|
||||||
// tokens
|
ExpectedData *data
|
||||||
AccessToken string
|
AccessToken string
|
||||||
RefreshToken string
|
RefreshToken string
|
||||||
TokenResponse string
|
TokenResponse string
|
||||||
// API response
|
|
||||||
JSONResponse string
|
JSONResponse string
|
||||||
// Cache
|
CacheJSONResponse string
|
||||||
RefreshTokenFromCache bool
|
Case string
|
||||||
AccessTokenFromCache bool
|
|
||||||
// Errors
|
|
||||||
Error error
|
|
||||||
// Validations
|
|
||||||
ExpectedErrorMessage string
|
ExpectedErrorMessage string
|
||||||
ExpectedData *data
|
CacheTimeout int
|
||||||
|
ResponseCacheMiss bool
|
||||||
|
AccessTokenFromCache bool
|
||||||
|
RefreshTokenFromCache bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "No initial tokens",
|
Case: "No initial tokens",
|
||||||
|
|
|
@ -31,14 +31,14 @@ func TestRequestResult(t *testing.T) {
|
||||||
url := "https://google.com?q=hello"
|
url := "https://google.com?q=hello"
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
|
||||||
// API response
|
|
||||||
JSONResponse string
|
|
||||||
// Errors
|
|
||||||
Error error
|
Error error
|
||||||
// Validations
|
|
||||||
ExpectedErrorMessage string
|
|
||||||
ExpectedData *data
|
ExpectedData *data
|
||||||
|
Case string
|
||||||
|
JSONResponse string
|
||||||
|
CacheJSONResponse string
|
||||||
|
ExpectedErrorMessage string
|
||||||
|
CacheTimeout int
|
||||||
|
ResponseCacheMiss bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "No cache",
|
Case: "No cache",
|
||||||
|
|
|
@ -33,20 +33,15 @@ import (
|
||||||
type Terminal struct {
|
type Terminal struct {
|
||||||
CmdFlags *Flags
|
CmdFlags *Flags
|
||||||
Var maps.Simple
|
Var maps.Simple
|
||||||
|
|
||||||
cwd string
|
|
||||||
host string
|
|
||||||
cmdCache *cache.Command
|
cmdCache *cache.Command
|
||||||
|
|
||||||
deviceCache *cache.File
|
deviceCache *cache.File
|
||||||
sessionCache *cache.File
|
sessionCache *cache.File
|
||||||
|
|
||||||
tmplCache *cache.Template
|
tmplCache *cache.Template
|
||||||
networks []*Connection
|
|
||||||
|
|
||||||
sync.RWMutex
|
|
||||||
|
|
||||||
lsDirMap maps.Concurrent
|
lsDirMap maps.Concurrent
|
||||||
|
cwd string
|
||||||
|
host string
|
||||||
|
networks []*Connection
|
||||||
|
sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (term *Terminal) Init() {
|
func (term *Terminal) Init() {
|
||||||
|
|
|
@ -28,8 +28,8 @@ type ArgocdContext struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ArgocdConfig struct {
|
type ArgocdConfig struct {
|
||||||
Contexts []*ArgocdContext `yaml:"contexts"`
|
|
||||||
CurrentContext string `yaml:"current-context"`
|
CurrentContext string `yaml:"current-context"`
|
||||||
|
Contexts []*ArgocdContext `yaml:"contexts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Argocd struct {
|
type Argocd struct {
|
||||||
|
|
|
@ -73,11 +73,11 @@ func TestArgocdGetConfigPath(t *testing.T) {
|
||||||
func TestArgocdParseConfig(t *testing.T) {
|
func TestArgocdParseConfig(t *testing.T) {
|
||||||
configFile := "/Users/posh/.config/argocd/config"
|
configFile := "/Users/posh/.config/argocd/config"
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
ExpectedContext ArgocdContext
|
||||||
Case string
|
Case string
|
||||||
Config string
|
Config string
|
||||||
Expected bool
|
|
||||||
ExpectedError string
|
ExpectedError string
|
||||||
ExpectedContext ArgocdContext
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{Case: "missing or empty yaml", Config: "", ExpectedError: argocdInvalidYaml},
|
{Case: "missing or empty yaml", Config: "", ExpectedError: argocdInvalidYaml},
|
||||||
{
|
{
|
||||||
|
@ -177,14 +177,14 @@ users:
|
||||||
func TestArgocdSegment(t *testing.T) {
|
func TestArgocdSegment(t *testing.T) {
|
||||||
configFile := path.Join(poshHome, ".config", "argocd", "config")
|
configFile := path.Join(poshHome, ".config", "argocd", "config")
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
ExpectedContext ArgocdContext
|
||||||
Case string
|
Case string
|
||||||
Opts string
|
Opts string
|
||||||
Config string
|
Config string
|
||||||
Template string
|
Template string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
ExpectedError string
|
ExpectedError string
|
||||||
ExpectedContext ArgocdContext
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "default template",
|
Case: "default template",
|
||||||
|
|
|
@ -14,7 +14,6 @@ func TestAWSSegment(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
Profile string
|
Profile string
|
||||||
DefaultProfile string
|
DefaultProfile string
|
||||||
Vault string
|
Vault string
|
||||||
|
@ -22,6 +21,7 @@ func TestAWSSegment(t *testing.T) {
|
||||||
DefaultRegion string
|
DefaultRegion string
|
||||||
ConfigFile string
|
ConfigFile string
|
||||||
Template string
|
Template string
|
||||||
|
ExpectedEnabled bool
|
||||||
DisplayDefault bool
|
DisplayDefault bool
|
||||||
}{
|
}{
|
||||||
{Case: "enabled with default user", ExpectedString: "default@eu-west", Region: "eu-west", ExpectedEnabled: true, DisplayDefault: true},
|
{Case: "enabled with default user", ExpectedString: "default@eu-west", Region: "eu-west", ExpectedEnabled: true, DisplayDefault: true},
|
||||||
|
|
|
@ -13,9 +13,8 @@ import (
|
||||||
type Az struct {
|
type Az struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
|
|
||||||
AzureSubscription
|
|
||||||
Origin string
|
Origin string
|
||||||
|
AzureSubscription
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -28,21 +27,21 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type AzureConfig struct {
|
type AzureConfig struct {
|
||||||
Subscriptions []*AzureSubscription `json:"subscriptions"`
|
|
||||||
InstallationID string `json:"installationId"`
|
InstallationID string `json:"installationId"`
|
||||||
|
Subscriptions []*AzureSubscription `json:"subscriptions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AzureSubscription struct {
|
type AzureSubscription struct {
|
||||||
|
User *AzureUser `json:"user"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
User *AzureUser `json:"user"`
|
|
||||||
IsDefault bool `json:"isDefault"`
|
|
||||||
TenantID string `json:"tenantId"`
|
TenantID string `json:"tenantId"`
|
||||||
TenantDisplayName string `json:"tenantDisplayName"`
|
TenantDisplayName string `json:"tenantDisplayName"`
|
||||||
EnvironmentName string `json:"environmentName"`
|
EnvironmentName string `json:"environmentName"`
|
||||||
HomeTenantID string `json:"homeTenantId"`
|
HomeTenantID string `json:"homeTenantId"`
|
||||||
ManagedByTenants []any `json:"managedByTenants"`
|
ManagedByTenants []any `json:"managedByTenants"`
|
||||||
|
IsDefault bool `json:"isDefault"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AzureUser struct {
|
type AzureUser struct {
|
||||||
|
|
|
@ -15,12 +15,12 @@ import (
|
||||||
func TestAzSegment(t *testing.T) {
|
func TestAzSegment(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
ExpectedEnabled bool
|
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
HasCLI bool
|
|
||||||
HasPowerShell bool
|
|
||||||
Template string
|
Template string
|
||||||
Source string
|
Source string
|
||||||
|
ExpectedEnabled bool
|
||||||
|
HasCLI bool
|
||||||
|
HasPowerShell bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "no config files found",
|
Case: "no config files found",
|
||||||
|
|
|
@ -17,8 +17,8 @@ type Azd struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type azdConfig struct {
|
type azdConfig struct {
|
||||||
Version int `json:"version"`
|
|
||||||
DefaultEnvironment string `json:"defaultEnvironment"`
|
DefaultEnvironment string `json:"defaultEnvironment"`
|
||||||
|
Version int `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Azd) Template() string {
|
func (t *Azd) Template() string {
|
||||||
|
|
|
@ -16,9 +16,9 @@ import (
|
||||||
func TestAzdSegment(t *testing.T) {
|
func TestAzdSegment(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
ExpectedEnabled bool
|
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
Template string
|
Template string
|
||||||
|
ExpectedEnabled bool
|
||||||
IsInited bool
|
IsInited bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,9 +6,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Bazel struct {
|
type Bazel struct {
|
||||||
language
|
|
||||||
|
|
||||||
Icon string
|
Icon string
|
||||||
|
language
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -18,18 +18,15 @@ import (
|
||||||
type Brewfather struct {
|
type Brewfather struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
|
DaysBottledOrFermented *uint
|
||||||
Batch
|
|
||||||
TemperatureTrendIcon string
|
TemperatureTrendIcon string
|
||||||
StatusIcon string
|
StatusIcon string
|
||||||
DayIcon string // populated from day_icon for use in template
|
DayIcon string
|
||||||
|
URL string
|
||||||
ReadingAge int // age in hours of the most recent reading included in the batch, -1 if none
|
Batch
|
||||||
|
ReadingAge int
|
||||||
DaysFermenting uint
|
DaysFermenting uint
|
||||||
DaysBottled uint
|
DaysBottled uint
|
||||||
DaysBottledOrFermented *uint // help avoid chronic template logic - code will point this to one of above or be nil depending on status
|
|
||||||
|
|
||||||
URL string // URL of batch page to open if hyperlink enabled on the segment and URL formatting used in template: «text»(link)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -64,34 +61,28 @@ const (
|
||||||
// Returned from https://api.brewfather.app/v1/batches/batch_id/readings
|
// Returned from https://api.brewfather.app/v1/batches/batch_id/readings
|
||||||
type BatchReading struct {
|
type BatchReading struct {
|
||||||
Comment string `json:"comment"`
|
Comment string `json:"comment"`
|
||||||
Gravity float64 `json:"sg"`
|
|
||||||
DeviceType string `json:"type"`
|
DeviceType string `json:"type"`
|
||||||
DeviceID string `json:"id"`
|
DeviceID string `json:"id"`
|
||||||
Temperature float64 `json:"temp"` // celsius - need to add F conversion
|
Gravity float64 `json:"sg"`
|
||||||
Timepoint int64 `json:"timepoint"` // << check what these are...
|
Temperature float64 `json:"temp"`
|
||||||
Time int64 `json:"time"` // <<
|
Timepoint int64 `json:"timepoint"`
|
||||||
|
Time int64 `json:"time"`
|
||||||
}
|
}
|
||||||
type Batch struct {
|
type Batch struct {
|
||||||
// Json tagged values returned from https://api.brewfather.app/v1/batches/batch_id
|
Reading *BatchReading
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
BatchName string `json:"name"`
|
BatchName string `json:"name"`
|
||||||
BatchNumber int `json:"batchNo"`
|
|
||||||
Recipe struct {
|
Recipe struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
} `json:"recipe"`
|
} `json:"recipe"`
|
||||||
|
BatchNumber int `json:"batchNo"`
|
||||||
BrewDate int64 `json:"brewDate"`
|
BrewDate int64 `json:"brewDate"`
|
||||||
FermentStartDate int64 `json:"fermentationStartDate"`
|
FermentStartDate int64 `json:"fermentationStartDate"`
|
||||||
BottlingDate int64 `json:"bottlingDate"`
|
BottlingDate int64 `json:"bottlingDate"`
|
||||||
|
|
||||||
MeasuredOg float64 `json:"measuredOg"`
|
MeasuredOg float64 `json:"measuredOg"`
|
||||||
MeasuredFg float64 `json:"measuredFg"`
|
MeasuredFg float64 `json:"measuredFg"`
|
||||||
MeasuredAbv float64 `json:"measuredAbv"`
|
MeasuredAbv float64 `json:"measuredAbv"`
|
||||||
|
TemperatureTrend float64
|
||||||
// copy of the latest BatchReading in here.
|
|
||||||
Reading *BatchReading
|
|
||||||
|
|
||||||
// Calculated values we need to cache because they require the rest query to reproduce
|
|
||||||
TemperatureTrend float64 // diff between this and last, short term trend
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bf *Brewfather) Template() string {
|
func (bf *Brewfather) Template() string {
|
||||||
|
|
|
@ -52,13 +52,15 @@ func TestBrewfatherSegment(t *testing.T) {
|
||||||
batchReadingJSON3 := `,"type":"manual"}, {"id":"manual","temp":15,"comment":"","sg":1.050,"time":`
|
batchReadingJSON3 := `,"type":"manual"}, {"id":"manual","temp":15,"comment":"","sg":1.050,"time":`
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Error error
|
||||||
Case string
|
Case string
|
||||||
BatchJSONResponse string
|
BatchJSONResponse string
|
||||||
BatchReadingsJSONResponse string
|
BatchReadingsJSONResponse string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
Template string
|
Template string
|
||||||
Error error
|
CacheTimeout int
|
||||||
|
ExpectedEnabled bool
|
||||||
|
CacheFoundFail bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Planning Status",
|
Case: "Planning Status",
|
||||||
|
|
|
@ -22,15 +22,15 @@ type CarbonIntensityResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CarbonIntensityPeriod struct {
|
type CarbonIntensityPeriod struct {
|
||||||
|
Intensity *CarbonIntensityData `json:"intensity"`
|
||||||
From string `json:"from"`
|
From string `json:"from"`
|
||||||
To string `json:"to"`
|
To string `json:"to"`
|
||||||
Intensity *CarbonIntensityData `json:"intensity"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CarbonIntensityData struct {
|
type CarbonIntensityData struct {
|
||||||
|
Index Index `json:"index"`
|
||||||
Forecast Number `json:"forecast"`
|
Forecast Number `json:"forecast"`
|
||||||
Actual Number `json:"actual"`
|
Actual Number `json:"actual"`
|
||||||
Index Index `json:"index"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Number int
|
type Number int
|
||||||
|
|
|
@ -20,14 +20,14 @@ const (
|
||||||
func TestCarbonIntensitySegmentSingle(t *testing.T) {
|
func TestCarbonIntensitySegmentSingle(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
HasError bool
|
|
||||||
HasData bool
|
|
||||||
Actual int
|
|
||||||
Forecast int
|
|
||||||
Index string
|
Index string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
Template string
|
Template string
|
||||||
|
Actual int
|
||||||
|
Forecast int
|
||||||
|
HasError bool
|
||||||
|
HasData bool
|
||||||
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Very Low, Going Down",
|
Case: "Very Low, Going Down",
|
||||||
|
|
|
@ -15,13 +15,13 @@ import (
|
||||||
|
|
||||||
func TestCFTargetSegment(t *testing.T) {
|
func TestCFTargetSegment(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
CommandError error
|
||||||
|
FileInfo *runtime.FileInfo
|
||||||
Case string
|
Case string
|
||||||
Template string
|
Template string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
DisplayMode string
|
DisplayMode string
|
||||||
FileInfo *runtime.FileInfo
|
|
||||||
TargetOutput string
|
TargetOutput string
|
||||||
CommandError error
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "not logged in to CF account",
|
Case: "not logged in to CF account",
|
||||||
|
|
|
@ -157,8 +157,8 @@ func TestExecuteScript(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Output string
|
Output string
|
||||||
HasScript bool
|
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
HasScript bool
|
||||||
ExpectedEnabled bool
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,9 +19,9 @@ func TestConnection(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
ConnectionType string
|
ConnectionType string
|
||||||
Connections []*connectionResponse
|
Connections []*connectionResponse
|
||||||
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "WiFi only, enabled",
|
Case: "WiFi only, enabled",
|
||||||
|
|
|
@ -15,12 +15,12 @@ func TestDockerSegment(t *testing.T) {
|
||||||
value string
|
value string
|
||||||
}
|
}
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
EnvVar envVar
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
ExpectedEnabled bool
|
|
||||||
EnvVar envVar
|
|
||||||
HasFiles bool
|
|
||||||
ConfigFile string
|
ConfigFile string
|
||||||
|
ExpectedEnabled bool
|
||||||
|
HasFiles bool
|
||||||
}{
|
}{
|
||||||
{Case: "DOCKER_MACHINE_NAME", Expected: "alpine", ExpectedEnabled: true, EnvVar: envVar{name: "DOCKER_MACHINE_NAME", value: "alpine"}},
|
{Case: "DOCKER_MACHINE_NAME", Expected: "alpine", ExpectedEnabled: true, EnvVar: envVar{name: "DOCKER_MACHINE_NAME", value: "alpine"}},
|
||||||
{Case: "DOCKER_HOST", Expected: "alpine 2", ExpectedEnabled: true, EnvVar: envVar{name: "DOCKER_HOST", value: "alpine 2"}},
|
{Case: "DOCKER_HOST", Expected: "alpine 2", ExpectedEnabled: true, EnvVar: envVar{name: "DOCKER_HOST", value: "alpine 2"}},
|
||||||
|
|
|
@ -13,8 +13,8 @@ func TestDotnetSegment(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
ExitCode int
|
|
||||||
Version string
|
Version string
|
||||||
|
ExitCode int
|
||||||
}{
|
}{
|
||||||
{Case: "Unsupported version", Expected: "\uf071", ExitCode: constants.DotnetExitCode, Version: "3.1.402"},
|
{Case: "Unsupported version", Expected: "\uf071", ExitCode: constants.DotnetExitCode, Version: "3.1.402"},
|
||||||
{Case: "Regular version", Expected: "3.1.402", Version: "3.1.402"},
|
{Case: "Regular version", Expected: "3.1.402", Version: "3.1.402"},
|
||||||
|
|
|
@ -19,8 +19,8 @@ func TestFirebaseSegment(t *testing.T) {
|
||||||
Case string
|
Case string
|
||||||
ActiveConfig string
|
ActiveConfig string
|
||||||
ActivePath string
|
ActivePath string
|
||||||
ExpectedEnabled bool
|
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "happy path",
|
Case: "happy path",
|
||||||
|
|
|
@ -27,10 +27,9 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Fossil struct {
|
type Fossil struct {
|
||||||
scm
|
|
||||||
|
|
||||||
Status *FossilStatus
|
Status *FossilStatus
|
||||||
Branch string
|
Branch string
|
||||||
|
scm
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Fossil) Template() string {
|
func (f *Fossil) Template() string {
|
||||||
|
|
|
@ -13,12 +13,12 @@ import (
|
||||||
|
|
||||||
func TestFossilStatus(t *testing.T) {
|
func TestFossilStatus(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
OutputError error
|
||||||
Case string
|
Case string
|
||||||
Output string
|
Output string
|
||||||
OutputError error
|
|
||||||
HasCommand bool
|
|
||||||
ExpectedStatus string
|
ExpectedStatus string
|
||||||
ExpectedBranch string
|
ExpectedBranch string
|
||||||
|
HasCommand bool
|
||||||
ExpectedDisabled bool
|
ExpectedDisabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,8 +16,8 @@ func TestGcpSegment(t *testing.T) {
|
||||||
Case string
|
Case string
|
||||||
CfgData string
|
CfgData string
|
||||||
ActiveConfig string
|
ActiveConfig string
|
||||||
ExpectedEnabled bool
|
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "happy path",
|
Case: "happy path",
|
||||||
|
|
|
@ -16,13 +16,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Commit struct {
|
type Commit struct {
|
||||||
// git log -1 --pretty="format:%an%n%ae%n%cn%n%ce%n%at%n%s"
|
Timestamp time.Time
|
||||||
Author *User
|
Author *User
|
||||||
Committer *User
|
Committer *User
|
||||||
Subject string
|
|
||||||
Timestamp time.Time
|
|
||||||
Sha string
|
|
||||||
Refs *Refs
|
Refs *Refs
|
||||||
|
Subject string
|
||||||
|
Sha string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Refs struct {
|
type Refs struct {
|
||||||
|
@ -129,37 +128,33 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Git struct {
|
type Git struct {
|
||||||
scm
|
User *User
|
||||||
|
|
||||||
Working *GitStatus
|
Working *GitStatus
|
||||||
Staging *GitStatus
|
Staging *GitStatus
|
||||||
Ahead int
|
commit *Commit
|
||||||
Behind int
|
UpstreamURL string
|
||||||
HEAD string
|
UpstreamIcon string
|
||||||
Ref string
|
Ref string
|
||||||
Hash string
|
Hash string
|
||||||
ShortHash string
|
ShortHash string
|
||||||
BranchStatus string
|
BranchStatus string
|
||||||
Upstream string
|
Upstream string
|
||||||
UpstreamIcon string
|
HEAD string
|
||||||
UpstreamURL string
|
|
||||||
RawUpstreamURL string
|
RawUpstreamURL string
|
||||||
UpstreamGone bool
|
scm
|
||||||
|
Ahead int
|
||||||
|
stashCount int
|
||||||
|
worktreeCount int
|
||||||
|
Behind int
|
||||||
IsWorkTree bool
|
IsWorkTree bool
|
||||||
IsBare bool
|
|
||||||
User *User
|
|
||||||
Detached bool
|
|
||||||
Merge bool
|
Merge bool
|
||||||
Rebase bool
|
Rebase bool
|
||||||
CherryPick bool
|
CherryPick bool
|
||||||
Revert bool
|
Revert bool
|
||||||
|
|
||||||
// needed for posh-git support
|
|
||||||
poshgit bool
|
poshgit bool
|
||||||
stashCount int
|
Detached bool
|
||||||
worktreeCount int
|
IsBare bool
|
||||||
|
UpstreamGone bool
|
||||||
commit *Commit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Git) Template() string {
|
func (g *Git) Template() string {
|
||||||
|
|
|
@ -74,13 +74,13 @@ func TestResolveEmptyGitPath(t *testing.T) {
|
||||||
func TestEnabledInWorktree(t *testing.T) {
|
func TestEnabledInWorktree(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
ExpectedEnabled bool
|
|
||||||
WorkingFolder string
|
WorkingFolder string
|
||||||
WorkingFolderAddon string
|
WorkingFolderAddon string
|
||||||
WorkingFolderContent string
|
WorkingFolderContent string
|
||||||
ExpectedRealFolder string
|
ExpectedRealFolder string
|
||||||
ExpectedWorkingFolder string
|
ExpectedWorkingFolder string
|
||||||
ExpectedRootFolder string
|
ExpectedRootFolder string
|
||||||
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "worktree",
|
Case: "worktree",
|
||||||
|
@ -156,12 +156,12 @@ func TestEnabledInBareRepo(t *testing.T) {
|
||||||
Case string
|
Case string
|
||||||
HEAD string
|
HEAD string
|
||||||
IsBare string
|
IsBare string
|
||||||
FetchRemote bool
|
|
||||||
Remote string
|
Remote string
|
||||||
RemoteURL string
|
RemoteURL string
|
||||||
ExpectedEnabled bool
|
|
||||||
ExpectedHEAD string
|
ExpectedHEAD string
|
||||||
ExpectedRemote string
|
ExpectedRemote string
|
||||||
|
FetchRemote bool
|
||||||
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Bare repo on main",
|
Case: "Bare repo on main",
|
||||||
|
@ -234,19 +234,19 @@ func TestGetGitOutputForCommand(t *testing.T) {
|
||||||
|
|
||||||
func TestSetGitHEADContextClean(t *testing.T) {
|
func TestSetGitHEADContextClean(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Ours string
|
||||||
Expected string
|
Expected string
|
||||||
Ref string
|
Ref string
|
||||||
RebaseMerge bool
|
Case string
|
||||||
RebaseApply bool
|
|
||||||
Merge bool
|
|
||||||
CherryPick bool
|
|
||||||
Revert bool
|
|
||||||
Sequencer bool
|
|
||||||
Ours string
|
|
||||||
Theirs string
|
|
||||||
Step string
|
|
||||||
Total string
|
Total string
|
||||||
|
Step string
|
||||||
|
Theirs string
|
||||||
|
RebaseMerge bool
|
||||||
|
Sequencer bool
|
||||||
|
Revert bool
|
||||||
|
CherryPick bool
|
||||||
|
Merge bool
|
||||||
|
RebaseApply bool
|
||||||
}{
|
}{
|
||||||
{Case: "detached on commit", Ref: DETACHED, Expected: "branch detached at commit 1234567"},
|
{Case: "detached on commit", Ref: DETACHED, Expected: "branch detached at commit 1234567"},
|
||||||
{Case: "not detached, clean", Ref: "main", Expected: "branch main"},
|
{Case: "not detached, clean", Ref: "main", Expected: "branch main"},
|
||||||
|
@ -428,16 +428,16 @@ func TestSetPrettyHEADName(t *testing.T) {
|
||||||
|
|
||||||
func TestSetGitStatus(t *testing.T) {
|
func TestSetGitStatus(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
|
||||||
Output string
|
|
||||||
ExpectedWorking *GitStatus
|
ExpectedWorking *GitStatus
|
||||||
ExpectedStaging *GitStatus
|
ExpectedStaging *GitStatus
|
||||||
|
Case string
|
||||||
|
Output string
|
||||||
ExpectedHash string
|
ExpectedHash string
|
||||||
ExpectedRef string
|
ExpectedRef string
|
||||||
ExpectedUpstream string
|
ExpectedUpstream string
|
||||||
ExpectedUpstreamGone bool
|
|
||||||
ExpectedAhead int
|
ExpectedAhead int
|
||||||
ExpectedBehind int
|
ExpectedBehind int
|
||||||
|
ExpectedUpstreamGone bool
|
||||||
Rebase bool
|
Rebase bool
|
||||||
Merge bool
|
Merge bool
|
||||||
}{
|
}{
|
||||||
|
@ -610,8 +610,8 @@ func TestSetGitStatus(t *testing.T) {
|
||||||
|
|
||||||
func TestGetStashContextZeroEntries(t *testing.T) {
|
func TestGetStashContextZeroEntries(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Expected int
|
|
||||||
StashContent string
|
StashContent string
|
||||||
|
Expected int
|
||||||
}{
|
}{
|
||||||
{Expected: 0, StashContent: ""},
|
{Expected: 0, StashContent: ""},
|
||||||
{Expected: 2, StashContent: "1\n2\n"},
|
{Expected: 2, StashContent: "1\n2\n"},
|
||||||
|
@ -714,9 +714,9 @@ func TestGetBranchStatus(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
|
Upstream string
|
||||||
Ahead int
|
Ahead int
|
||||||
Behind int
|
Behind int
|
||||||
Upstream string
|
|
||||||
UpstreamGone bool
|
UpstreamGone bool
|
||||||
}{
|
}{
|
||||||
{Case: "Equal with remote", Expected: "equal", Upstream: branchName},
|
{Case: "Equal with remote", Expected: "equal", Upstream: branchName},
|
||||||
|
@ -751,10 +751,10 @@ func TestGetBranchStatus(t *testing.T) {
|
||||||
|
|
||||||
func TestGitTemplateString(t *testing.T) {
|
func TestGitTemplateString(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Git *Git
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
Template string
|
Template string
|
||||||
Git *Git
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Only HEAD name",
|
Case: "Only HEAD name",
|
||||||
|
@ -886,9 +886,9 @@ func TestGitTemplateString(t *testing.T) {
|
||||||
|
|
||||||
func TestGitUntrackedMode(t *testing.T) {
|
func TestGitUntrackedMode(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
UntrackedModes map[string]string
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
UntrackedModes map[string]string
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Default mode - no map",
|
Case: "Default mode - no map",
|
||||||
|
@ -934,9 +934,9 @@ func TestGitUntrackedMode(t *testing.T) {
|
||||||
|
|
||||||
func TestGitIgnoreSubmodules(t *testing.T) {
|
func TestGitIgnoreSubmodules(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
IgnoreSubmodules map[string]string
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
IgnoreSubmodules map[string]string
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Overide",
|
Case: "Overide",
|
||||||
|
@ -1107,8 +1107,8 @@ func TestGitCommit(t *testing.T) {
|
||||||
func TestGitRemotes(t *testing.T) {
|
func TestGitRemotes(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Expected int
|
|
||||||
Config string
|
Config string
|
||||||
|
Expected int
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Empty config file",
|
Case: "Empty config file",
|
||||||
|
|
|
@ -8,39 +8,39 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type gitVersion struct {
|
type gitVersion struct {
|
||||||
Major int `json:"Major"`
|
NuGetVersionV2 string `json:"NuGetVersionV2"`
|
||||||
Minor int `json:"Minor"`
|
FullSemVer string `json:"FullSemVer"`
|
||||||
Patch int `json:"Patch"`
|
CommitDate string `json:"CommitDate"`
|
||||||
PreReleaseTag string `json:"PreReleaseTag"`
|
AssemblySemVer string `json:"AssemblySemVer"`
|
||||||
PreReleaseTagWithDash string `json:"PreReleaseTagWithDash"`
|
PreReleaseTagWithDash string `json:"PreReleaseTagWithDash"`
|
||||||
PreReleaseLabel string `json:"PreReleaseLabel"`
|
PreReleaseLabel string `json:"PreReleaseLabel"`
|
||||||
PreReleaseLabelWithDash string `json:"PreReleaseLabelWithDash"`
|
PreReleaseLabelWithDash string `json:"PreReleaseLabelWithDash"`
|
||||||
PreReleaseNumber int `json:"PreReleaseNumber"`
|
AssemblySemFileVer string `json:"AssemblySemFileVer"`
|
||||||
WeightedPreReleaseNumber int `json:"WeightedPreReleaseNumber"`
|
CommitsSinceVersionSourcePadded string `json:"CommitsSinceVersionSourcePadded"`
|
||||||
BuildMetaData int `json:"BuildMetaData"`
|
VersionSourceSha string `json:"VersionSourceSha"`
|
||||||
BuildMetaDataPadded string `json:"BuildMetaDataPadded"`
|
BuildMetaDataPadded string `json:"BuildMetaDataPadded"`
|
||||||
FullBuildMetaData string `json:"FullBuildMetaData"`
|
FullBuildMetaData string `json:"FullBuildMetaData"`
|
||||||
MajorMinorPatch string `json:"MajorMinorPatch"`
|
MajorMinorPatch string `json:"MajorMinorPatch"`
|
||||||
SemVer string `json:"SemVer"`
|
NuGetVersion string `json:"NuGetVersion"`
|
||||||
LegacySemVer string `json:"LegacySemVer"`
|
LegacySemVer string `json:"LegacySemVer"`
|
||||||
LegacySemVerPadded string `json:"LegacySemVerPadded"`
|
LegacySemVerPadded string `json:"LegacySemVerPadded"`
|
||||||
AssemblySemVer string `json:"AssemblySemVer"`
|
PreReleaseTag string `json:"PreReleaseTag"`
|
||||||
AssemblySemFileVer string `json:"AssemblySemFileVer"`
|
NuGetPreReleaseTag string `json:"NuGetPreReleaseTag"`
|
||||||
FullSemVer string `json:"FullSemVer"`
|
SemVer string `json:"SemVer"`
|
||||||
InformationalVersion string `json:"InformationalVersion"`
|
InformationalVersion string `json:"InformationalVersion"`
|
||||||
BranchName string `json:"BranchName"`
|
BranchName string `json:"BranchName"`
|
||||||
EscapedBranchName string `json:"EscapedBranchName"`
|
EscapedBranchName string `json:"EscapedBranchName"`
|
||||||
Sha string `json:"Sha"`
|
Sha string `json:"Sha"`
|
||||||
ShortSha string `json:"ShortSha"`
|
ShortSha string `json:"ShortSha"`
|
||||||
NuGetVersionV2 string `json:"NuGetVersionV2"`
|
|
||||||
NuGetVersion string `json:"NuGetVersion"`
|
|
||||||
NuGetPreReleaseTagV2 string `json:"NuGetPreReleaseTagV2"`
|
NuGetPreReleaseTagV2 string `json:"NuGetPreReleaseTagV2"`
|
||||||
NuGetPreReleaseTag string `json:"NuGetPreReleaseTag"`
|
BuildMetaData int `json:"BuildMetaData"`
|
||||||
VersionSourceSha string `json:"VersionSourceSha"`
|
Major int `json:"Major"`
|
||||||
|
PreReleaseNumber int `json:"PreReleaseNumber"`
|
||||||
|
Minor int `json:"Minor"`
|
||||||
CommitsSinceVersionSource int `json:"CommitsSinceVersionSource"`
|
CommitsSinceVersionSource int `json:"CommitsSinceVersionSource"`
|
||||||
CommitsSinceVersionSourcePadded string `json:"CommitsSinceVersionSourcePadded"`
|
WeightedPreReleaseNumber int `json:"WeightedPreReleaseNumber"`
|
||||||
UncommittedChanges int `json:"UncommittedChanges"`
|
UncommittedChanges int `json:"UncommittedChanges"`
|
||||||
CommitDate string `json:"CommitDate"`
|
Patch int `json:"Patch"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GitVersion struct {
|
type GitVersion struct {
|
||||||
|
|
|
@ -12,13 +12,16 @@ import (
|
||||||
|
|
||||||
func TestGitversion(t *testing.T) {
|
func TestGitversion(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
CacheError error
|
||||||
|
CommandError error
|
||||||
Case string
|
Case string
|
||||||
ExpectedEnabled bool
|
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
Response string
|
Response string
|
||||||
HasGitversion bool
|
CacheResponse string
|
||||||
Template string
|
Template string
|
||||||
CommandError error
|
CacheTimeout int
|
||||||
|
ExpectedEnabled bool
|
||||||
|
HasGitversion bool
|
||||||
}{
|
}{
|
||||||
{Case: "GitVersion not installed"},
|
{Case: "GitVersion not installed"},
|
||||||
{Case: "GitVersion installed, no GitVersion.yml file", HasGitversion: true, Response: "Cannot find the .git directory"},
|
{Case: "GitVersion installed, no GitVersion.yml file", HasGitversion: true, Response: "Cannot find the .git directory"},
|
||||||
|
|
|
@ -15,12 +15,12 @@ import (
|
||||||
func TestHelmSegment(t *testing.T) {
|
func TestHelmSegment(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
HelmExists bool
|
|
||||||
ExpectedEnabled bool
|
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
Template string
|
Template string
|
||||||
DisplayMode string
|
DisplayMode string
|
||||||
ChartFile string
|
ChartFile string
|
||||||
|
HelmExists bool
|
||||||
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Helm not installed",
|
Case: "Helm not installed",
|
||||||
|
|
|
@ -26,9 +26,8 @@ func (i *ipAPI) Get() (*ipData, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPify struct {
|
type IPify struct {
|
||||||
IP string
|
|
||||||
|
|
||||||
api IPAPI
|
api IPAPI
|
||||||
|
IP string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -19,12 +19,9 @@ const (
|
||||||
type Kubectl struct {
|
type Kubectl struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
|
|
||||||
dirty bool
|
|
||||||
|
|
||||||
Context string
|
|
||||||
|
|
||||||
KubeContext
|
KubeContext
|
||||||
|
Context string
|
||||||
|
dirty bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type KubeConfig struct {
|
type KubeConfig struct {
|
||||||
|
|
|
@ -23,21 +23,21 @@ func TestKubectlSegment(t *testing.T) {
|
||||||
lsep := string(filepath.ListSeparator)
|
lsep := string(filepath.ListSeparator)
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Files map[string]string
|
||||||
Template string
|
ContextAliases map[string]string
|
||||||
DisplayError bool
|
Cluster string
|
||||||
KubectlExists bool
|
|
||||||
Kubeconfig string
|
Kubeconfig string
|
||||||
ParseKubeConfig bool
|
|
||||||
Context string
|
Context string
|
||||||
Namespace string
|
Namespace string
|
||||||
UserName string
|
UserName string
|
||||||
Cluster string
|
Case string
|
||||||
|
ExpectedString string
|
||||||
|
Template string
|
||||||
|
KubectlExists bool
|
||||||
|
ParseKubeConfig bool
|
||||||
KubectlErr bool
|
KubectlErr bool
|
||||||
ExpectedEnabled bool
|
ExpectedEnabled bool
|
||||||
ExpectedString string
|
DisplayError bool
|
||||||
Files map[string]string
|
|
||||||
ContextAliases map[string]string
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "kubeconfig incomplete",
|
Case: "kubeconfig incomplete",
|
||||||
|
|
|
@ -35,11 +35,11 @@ type version struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type cmd struct {
|
type cmd struct {
|
||||||
executable string
|
|
||||||
args []string
|
|
||||||
regex string
|
|
||||||
getVersion getVersion
|
getVersion getVersion
|
||||||
|
executable string
|
||||||
|
regex string
|
||||||
versionURLTemplate string
|
versionURLTemplate string
|
||||||
|
args []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmd) parse(versionInfo string) (*version, error) {
|
func (c *cmd) parse(versionInfo string) (*version, error) {
|
||||||
|
@ -60,24 +60,22 @@ func (c *cmd) parse(versionInfo string) (*version, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type language struct {
|
type language struct {
|
||||||
props properties.Properties
|
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
extensions []string
|
props properties.Properties
|
||||||
folders []string
|
projectRoot *runtime.FileInfo
|
||||||
commands []*cmd
|
|
||||||
versionURLTemplate string
|
|
||||||
exitCode int
|
|
||||||
loadContext loadContext
|
loadContext loadContext
|
||||||
inContext inContext
|
inContext inContext
|
||||||
matchesVersionFile matchesVersionFile
|
matchesVersionFile matchesVersionFile
|
||||||
homeEnabled bool
|
|
||||||
displayMode string
|
|
||||||
// root is the root folder of the project
|
|
||||||
projectFiles []string
|
|
||||||
projectRoot *runtime.FileInfo
|
|
||||||
|
|
||||||
version
|
version
|
||||||
|
displayMode string
|
||||||
Error string
|
Error string
|
||||||
|
versionURLTemplate string
|
||||||
|
commands []*cmd
|
||||||
|
projectFiles []string
|
||||||
|
folders []string
|
||||||
|
extensions []string
|
||||||
|
exitCode int
|
||||||
|
homeEnabled bool
|
||||||
Mismatch bool
|
Mismatch bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,15 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type languageArgs struct {
|
type languageArgs struct {
|
||||||
|
expectedError error
|
||||||
|
properties properties.Properties
|
||||||
|
matchesVersionFile matchesVersionFile
|
||||||
version string
|
version string
|
||||||
|
versionURLTemplate string
|
||||||
extensions []string
|
extensions []string
|
||||||
enabledExtensions []string
|
enabledExtensions []string
|
||||||
commands []*cmd
|
commands []*cmd
|
||||||
enabledCommands []string
|
enabledCommands []string
|
||||||
versionURLTemplate string
|
|
||||||
expectedError error
|
|
||||||
properties properties.Properties
|
|
||||||
matchesVersionFile matchesVersionFile
|
|
||||||
inHome bool
|
inHome bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,12 @@ const (
|
||||||
|
|
||||||
func TestLFMSegmentSingle(t *testing.T) {
|
func TestLFMSegmentSingle(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Error error
|
||||||
Case string
|
Case string
|
||||||
APIJSONResponse string
|
APIJSONResponse string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
Template string
|
Template string
|
||||||
Error error
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "All Defaults",
|
Case: "All Defaults",
|
||||||
|
|
|
@ -13,10 +13,10 @@ func TestLua(t *testing.T) {
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
Version string
|
Version string
|
||||||
HasLua bool
|
|
||||||
HasLuaJit bool
|
|
||||||
Prefer string
|
Prefer string
|
||||||
ExpectedURL string
|
ExpectedURL string
|
||||||
|
HasLua bool
|
||||||
|
HasLuaJit bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Lua 5.4.4 - Prefer Lua",
|
Case: "Lua 5.4.4 - Prefer Lua",
|
||||||
|
|
|
@ -30,16 +30,15 @@ func (s *MercurialStatus) add(code string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mercurial struct {
|
type Mercurial struct {
|
||||||
scm
|
|
||||||
|
|
||||||
Working *MercurialStatus
|
Working *MercurialStatus
|
||||||
IsTip bool
|
|
||||||
LocalCommitNumber string
|
LocalCommitNumber string
|
||||||
ChangeSetID string
|
ChangeSetID string
|
||||||
ChangeSetIDShort string
|
ChangeSetIDShort string
|
||||||
Branch string
|
Branch string
|
||||||
|
scm
|
||||||
Bookmarks []string
|
Bookmarks []string
|
||||||
Tags []string
|
Tags []string
|
||||||
|
IsTip bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hg *Mercurial) Template() string {
|
func (hg *Mercurial) Template() string {
|
||||||
|
|
|
@ -56,17 +56,17 @@ func TestMercurialEnabledInWorkingDirectory(t *testing.T) {
|
||||||
|
|
||||||
func TestMercurialGetIdInfo(t *testing.T) {
|
func TestMercurialGetIdInfo(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
ExpectedWorking *MercurialStatus
|
||||||
Case string
|
Case string
|
||||||
LogOutput string
|
LogOutput string
|
||||||
StatusOutput string
|
StatusOutput string
|
||||||
ExpectedWorking *MercurialStatus
|
|
||||||
ExpectedBranch string
|
ExpectedBranch string
|
||||||
ExpectedChangeSetID string
|
ExpectedChangeSetID string
|
||||||
ExpectedShortID string
|
ExpectedShortID string
|
||||||
ExpectedLocalCommitNumber string
|
ExpectedLocalCommitNumber string
|
||||||
ExpectedIsTip bool
|
|
||||||
ExpectedBookmarks []string
|
ExpectedBookmarks []string
|
||||||
ExpectedTags []string
|
ExpectedTags []string
|
||||||
|
ExpectedIsTip bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "nochanges_tip",
|
Case: "nochanges_tip",
|
||||||
|
|
|
@ -15,8 +15,8 @@ func TestMvn(t *testing.T) {
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
MvnVersion string
|
MvnVersion string
|
||||||
HasMvnw bool
|
|
||||||
MvnwVersion string
|
MvnwVersion string
|
||||||
|
HasMvnw bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Maven version",
|
Case: "Maven version",
|
||||||
|
|
|
@ -107,11 +107,11 @@ type Scoreboard struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
GameStatus int `json:"gameStatus"`
|
|
||||||
GameStatusText string `json:"gameStatusText"`
|
GameStatusText string `json:"gameStatusText"`
|
||||||
GameTimeUTC string `json:"gameTimeUTC"`
|
GameTimeUTC string `json:"gameTimeUTC"`
|
||||||
HomeTeam Team `json:"homeTeam"`
|
HomeTeam Team `json:"homeTeam"`
|
||||||
AwayTeam Team `json:"awayTeam"`
|
AwayTeam Team `json:"awayTeam"`
|
||||||
|
GameStatus int `json:"gameStatus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Team struct {
|
type Team struct {
|
||||||
|
|
|
@ -24,13 +24,15 @@ func TestNBASegment(t *testing.T) {
|
||||||
jsonScoreData := getTestData("nba/score.json")
|
jsonScoreData := getTestData("nba/score.json")
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Error error
|
||||||
Case string
|
Case string
|
||||||
JSONResponse string
|
JSONResponse string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
TeamName string
|
TeamName string
|
||||||
|
CacheTimeout int
|
||||||
DaysOffset int
|
DaysOffset int
|
||||||
Error error
|
ExpectedEnabled bool
|
||||||
|
CacheFoundFail bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Team (Home Team) Scheduled Game",
|
Case: "Team (Home Team) Scheduled Game",
|
||||||
|
|
|
@ -15,7 +15,6 @@ type Nbgv struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type VersionInfo struct {
|
type VersionInfo struct {
|
||||||
VersionFileFound bool `json:"VersionFileFound"`
|
|
||||||
Version string `json:"Version"`
|
Version string `json:"Version"`
|
||||||
AssemblyVersion string `json:"AssemblyVersion"`
|
AssemblyVersion string `json:"AssemblyVersion"`
|
||||||
AssemblyInformationalVersion string `json:"AssemblyInformationalVersion"`
|
AssemblyInformationalVersion string `json:"AssemblyInformationalVersion"`
|
||||||
|
@ -23,6 +22,7 @@ type VersionInfo struct {
|
||||||
ChocolateyPackageVersion string `json:"ChocolateyPackageVersion"`
|
ChocolateyPackageVersion string `json:"ChocolateyPackageVersion"`
|
||||||
NpmPackageVersion string `json:"NpmPackageVersion"`
|
NpmPackageVersion string `json:"NpmPackageVersion"`
|
||||||
SimpleVersion string `json:"SimpleVersion"`
|
SimpleVersion string `json:"SimpleVersion"`
|
||||||
|
VersionFileFound bool `json:"VersionFileFound"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Nbgv) Template() string {
|
func (n *Nbgv) Template() string {
|
||||||
|
|
|
@ -12,13 +12,13 @@ import (
|
||||||
|
|
||||||
func TestNbgv(t *testing.T) {
|
func TestNbgv(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Error error
|
||||||
Case string
|
Case string
|
||||||
ExpectedEnabled bool
|
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
Response string
|
Response string
|
||||||
HasNbgv bool
|
|
||||||
Template string
|
Template string
|
||||||
Error error
|
ExpectedEnabled bool
|
||||||
|
HasNbgv bool
|
||||||
}{
|
}{
|
||||||
{Case: "nbgv not installed"},
|
{Case: "nbgv not installed"},
|
||||||
{Case: "nbgv installed, no version file", HasNbgv: true, Response: "{ \"VersionFileFound\": false }"},
|
{Case: "nbgv installed, no version file", HasNbgv: true, Response: "{ \"VersionFileFound\": false }"},
|
||||||
|
|
|
@ -14,9 +14,8 @@ import (
|
||||||
type Nightscout struct {
|
type Nightscout struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
|
|
||||||
NightscoutData
|
|
||||||
TrendIcon string
|
TrendIcon string
|
||||||
|
NightscoutData
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -35,16 +34,16 @@ const (
|
||||||
|
|
||||||
// NightscoutData struct contains the API data
|
// NightscoutData struct contains the API data
|
||||||
type NightscoutData struct {
|
type NightscoutData struct {
|
||||||
ID string `json:"_id"`
|
|
||||||
Sgv int `json:"sgv"`
|
|
||||||
Date int64 `json:"date"`
|
|
||||||
DateString time.Time `json:"dateString"`
|
DateString time.Time `json:"dateString"`
|
||||||
Trend int `json:"trend"`
|
SysTime time.Time `json:"sysTime"`
|
||||||
|
ID string `json:"_id"`
|
||||||
Direction string `json:"direction"`
|
Direction string `json:"direction"`
|
||||||
Device string `json:"device"`
|
Device string `json:"device"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
Sgv int `json:"sgv"`
|
||||||
|
Date int64 `json:"date"`
|
||||||
|
Trend int `json:"trend"`
|
||||||
UtcOffset int `json:"utcOffset"`
|
UtcOffset int `json:"utcOffset"`
|
||||||
SysTime time.Time `json:"sysTime"`
|
|
||||||
Mills int64 `json:"mills"`
|
Mills int64 `json:"mills"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,14 @@ const (
|
||||||
|
|
||||||
func TestNSSegment(t *testing.T) {
|
func TestNSSegment(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Error error
|
||||||
Case string
|
Case string
|
||||||
JSONResponse string
|
JSONResponse string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
Template string
|
Template string
|
||||||
Error error
|
CacheTimeout int
|
||||||
|
ExpectedEnabled bool
|
||||||
|
CacheFoundFail bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Flat 150",
|
Case: "Flat 150",
|
||||||
|
|
|
@ -10,9 +10,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
language
|
|
||||||
|
|
||||||
PackageManagerIcon string
|
PackageManagerIcon string
|
||||||
|
language
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -18,9 +18,9 @@ func TestNodeMatchesVersionFile(t *testing.T) {
|
||||||
}
|
}
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Expected bool
|
|
||||||
ExpectedVersion string
|
ExpectedVersion string
|
||||||
RCVersion string
|
RCVersion string
|
||||||
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{Case: "no file context", Expected: true, RCVersion: ""},
|
{Case: "no file context", Expected: true, RCVersion: ""},
|
||||||
{Case: "version match", Expected: true, ExpectedVersion: "20.14.0", RCVersion: "20.14.0"},
|
{Case: "version match", Expected: true, ExpectedVersion: "20.14.0", RCVersion: "20.14.0"},
|
||||||
|
@ -55,12 +55,12 @@ func TestNodeMatchesVersionFile(t *testing.T) {
|
||||||
func TestNodeInContext(t *testing.T) {
|
func TestNodeInContext(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
|
ExpectedString string
|
||||||
hasPNPM bool
|
hasPNPM bool
|
||||||
hasYarn bool
|
hasYarn bool
|
||||||
hasNPM bool
|
hasNPM bool
|
||||||
hasDefault bool
|
hasDefault bool
|
||||||
PkgMgrEnabled bool
|
PkgMgrEnabled bool
|
||||||
ExpectedString string
|
|
||||||
}{
|
}{
|
||||||
{Case: "no package manager file", ExpectedString: "", PkgMgrEnabled: true},
|
{Case: "no package manager file", ExpectedString: "", PkgMgrEnabled: true},
|
||||||
{Case: "pnpm", hasPNPM: true, ExpectedString: "pnpm", PkgMgrEnabled: true},
|
{Case: "pnpm", hasPNPM: true, ExpectedString: "pnpm", PkgMgrEnabled: true},
|
||||||
|
|
|
@ -15,10 +15,10 @@ func TestOSInfo(t *testing.T) {
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
GOOS string
|
GOOS string
|
||||||
IsWSL bool
|
|
||||||
Platform string
|
Platform string
|
||||||
DisplayDistroName bool
|
|
||||||
Icon string
|
Icon string
|
||||||
|
IsWSL bool
|
||||||
|
DisplayDistroName bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "WSL debian - icon",
|
Case: "WSL debian - icon",
|
||||||
|
|
|
@ -14,12 +14,11 @@ import (
|
||||||
type Owm struct {
|
type Owm struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
|
|
||||||
Temperature int
|
|
||||||
Weather string
|
Weather string
|
||||||
URL string
|
URL string
|
||||||
units string
|
units string
|
||||||
UnitIcon string
|
UnitIcon string
|
||||||
|
Temperature int
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -19,13 +19,13 @@ const (
|
||||||
|
|
||||||
func TestOWMSegmentSingle(t *testing.T) {
|
func TestOWMSegmentSingle(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Error error
|
||||||
Case string
|
Case string
|
||||||
Location string
|
Location string
|
||||||
WeatherJSONResponse string
|
WeatherJSONResponse string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
Template string
|
Template string
|
||||||
Error error
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Sunny Display",
|
Case: "Sunny Display",
|
||||||
|
|
|
@ -15,8 +15,8 @@ import (
|
||||||
|
|
||||||
type Folder struct {
|
type Folder struct {
|
||||||
Name string
|
Name string
|
||||||
Display bool
|
|
||||||
Path string
|
Path string
|
||||||
|
Display bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Folders []*Folder
|
type Folders []*Folder
|
||||||
|
@ -34,23 +34,19 @@ func (f Folders) List() []string {
|
||||||
type Path struct {
|
type Path struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
|
mappedLocations map[string]string
|
||||||
pwd string
|
|
||||||
root string
|
root string
|
||||||
relative string
|
relative string
|
||||||
folders Folders
|
pwd string
|
||||||
// After `setPaths` is called, the above 4 fields should remain unchanged to preserve the original path info.
|
|
||||||
|
|
||||||
cygPath bool
|
|
||||||
windowsPath bool
|
|
||||||
pathSeparator string
|
|
||||||
mappedLocations map[string]string
|
|
||||||
|
|
||||||
Path string
|
|
||||||
StackCount int
|
|
||||||
Location string
|
Location string
|
||||||
|
pathSeparator string
|
||||||
|
Path string
|
||||||
|
Folders Folders
|
||||||
|
StackCount int
|
||||||
|
windowsPath bool
|
||||||
Writable bool
|
Writable bool
|
||||||
RootDir bool
|
RootDir bool
|
||||||
|
cygPath bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -142,7 +138,7 @@ func (pt *Path) Enabled() bool {
|
||||||
|
|
||||||
func (pt *Path) setPaths() {
|
func (pt *Path) setPaths() {
|
||||||
defer func() {
|
defer func() {
|
||||||
pt.folders = pt.splitPath()
|
pt.Folders = pt.splitPath()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
displayCygpath := func() bool {
|
displayCygpath := func() bool {
|
||||||
|
@ -177,7 +173,7 @@ func (pt *Path) Parent() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
folders := pt.folders.List()
|
folders := pt.Folders.List()
|
||||||
if len(folders) == 0 {
|
if len(folders) == 0 {
|
||||||
// No parent.
|
// No parent.
|
||||||
return ""
|
return ""
|
||||||
|
@ -300,7 +296,7 @@ func (pt *Path) getFolderSeparator() string {
|
||||||
|
|
||||||
func (pt *Path) getMixedPath() string {
|
func (pt *Path) getMixedPath() string {
|
||||||
root := pt.root
|
root := pt.root
|
||||||
folders := pt.folders
|
folders := pt.Folders
|
||||||
threshold := int(pt.props.GetFloat64(MixedThreshold, 4))
|
threshold := int(pt.props.GetFloat64(MixedThreshold, 4))
|
||||||
folderIcon := pt.props.GetString(FolderIcon, "..")
|
folderIcon := pt.props.GetString(FolderIcon, "..")
|
||||||
|
|
||||||
|
@ -326,7 +322,7 @@ func (pt *Path) getMixedPath() string {
|
||||||
|
|
||||||
func (pt *Path) getAgnosterPath() string {
|
func (pt *Path) getAgnosterPath() string {
|
||||||
root := pt.root
|
root := pt.root
|
||||||
folders := pt.folders
|
folders := pt.Folders
|
||||||
folderIcon := pt.props.GetString(FolderIcon, "..")
|
folderIcon := pt.props.GetString(FolderIcon, "..")
|
||||||
|
|
||||||
if pt.isRootFS(root) {
|
if pt.isRootFS(root) {
|
||||||
|
@ -350,7 +346,7 @@ func (pt *Path) getAgnosterPath() string {
|
||||||
|
|
||||||
func (pt *Path) getAgnosterLeftPath() string {
|
func (pt *Path) getAgnosterLeftPath() string {
|
||||||
root := pt.root
|
root := pt.root
|
||||||
folders := pt.folders
|
folders := pt.Folders
|
||||||
folderIcon := pt.props.GetString(FolderIcon, "..")
|
folderIcon := pt.props.GetString(FolderIcon, "..")
|
||||||
|
|
||||||
if pt.isRootFS(root) {
|
if pt.isRootFS(root) {
|
||||||
|
@ -391,7 +387,7 @@ func (pt *Path) getRelevantLetter(folder *Folder) string {
|
||||||
|
|
||||||
func (pt *Path) getLetterPath() string {
|
func (pt *Path) getLetterPath() string {
|
||||||
root := pt.root
|
root := pt.root
|
||||||
folders := pt.folders
|
folders := pt.Folders
|
||||||
|
|
||||||
if pt.isRootFS(root) {
|
if pt.isRootFS(root) {
|
||||||
root = folders[0].Name
|
root = folders[0].Name
|
||||||
|
@ -416,7 +412,7 @@ func (pt *Path) getLetterPath() string {
|
||||||
|
|
||||||
func (pt *Path) getUniqueLettersPath(maxWidth int) string {
|
func (pt *Path) getUniqueLettersPath(maxWidth int) string {
|
||||||
root := pt.root
|
root := pt.root
|
||||||
folders := pt.folders
|
folders := pt.Folders
|
||||||
separator := pt.getFolderSeparator()
|
separator := pt.getFolderSeparator()
|
||||||
|
|
||||||
if pt.isRootFS(root) {
|
if pt.isRootFS(root) {
|
||||||
|
@ -484,7 +480,7 @@ func (pt *Path) getUniqueLettersPath(maxWidth int) string {
|
||||||
|
|
||||||
func (pt *Path) getAgnosterFullPath() string {
|
func (pt *Path) getAgnosterFullPath() string {
|
||||||
root := pt.root
|
root := pt.root
|
||||||
folders := pt.folders
|
folders := pt.Folders
|
||||||
|
|
||||||
if pt.isRootFS(root) {
|
if pt.isRootFS(root) {
|
||||||
root = folders[0].Name
|
root = folders[0].Name
|
||||||
|
@ -496,7 +492,7 @@ func (pt *Path) getAgnosterFullPath() string {
|
||||||
|
|
||||||
func (pt *Path) getAgnosterShortPath() string {
|
func (pt *Path) getAgnosterShortPath() string {
|
||||||
root := pt.root
|
root := pt.root
|
||||||
folders := pt.folders
|
folders := pt.Folders
|
||||||
|
|
||||||
if pt.isRootFS(root) {
|
if pt.isRootFS(root) {
|
||||||
root = folders[0].Name
|
root = folders[0].Name
|
||||||
|
@ -531,11 +527,11 @@ func (pt *Path) getAgnosterShortPath() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pt *Path) getFullPath() string {
|
func (pt *Path) getFullPath() string {
|
||||||
return pt.colorizePath(pt.root, pt.folders.List())
|
return pt.colorizePath(pt.root, pt.Folders.List())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pt *Path) getFolderPath() string {
|
func (pt *Path) getFolderPath() string {
|
||||||
folderName := pt.folders[len(pt.folders)-1].Name
|
folderName := pt.Folders[len(pt.Folders)-1].Name
|
||||||
return pt.colorizePath(folderName, nil)
|
return pt.colorizePath(folderName, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,18 +165,18 @@ func TestParent(t *testing.T) {
|
||||||
|
|
||||||
func TestAgnosterPathStyles(t *testing.T) {
|
func TestAgnosterPathStyles(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Style string
|
CygpathError error
|
||||||
Expected string
|
GOOS string
|
||||||
HomePath string
|
Shell string
|
||||||
Pswd string
|
Pswd string
|
||||||
Pwd string
|
Pwd string
|
||||||
PathSeparator string
|
PathSeparator string
|
||||||
HomeIcon string
|
HomeIcon string
|
||||||
|
HomePath string
|
||||||
|
Style string
|
||||||
FolderSeparatorIcon string
|
FolderSeparatorIcon string
|
||||||
GOOS string
|
|
||||||
Shell string
|
|
||||||
Cygpath string
|
Cygpath string
|
||||||
CygpathError error
|
Expected string
|
||||||
MaxDepth int
|
MaxDepth int
|
||||||
MaxWidth int
|
MaxWidth int
|
||||||
HideRootLocation bool
|
HideRootLocation bool
|
||||||
|
@ -816,11 +816,11 @@ func TestFullAndFolderPath(t *testing.T) {
|
||||||
Pwd string
|
Pwd string
|
||||||
Pswd string
|
Pswd string
|
||||||
Expected string
|
Expected string
|
||||||
DisableMappedLocations bool
|
|
||||||
GOOS string
|
GOOS string
|
||||||
PathSeparator string
|
PathSeparator string
|
||||||
StackCount int
|
|
||||||
Template string
|
Template string
|
||||||
|
StackCount int
|
||||||
|
DisableMappedLocations bool
|
||||||
}{
|
}{
|
||||||
{Style: Full, FolderSeparatorIcon: "|", Pwd: "/", Expected: "/"},
|
{Style: Full, FolderSeparatorIcon: "|", Pwd: "/", Expected: "/"},
|
||||||
{Style: Full, Pwd: "/", Expected: "/"},
|
{Style: Full, Pwd: "/", Expected: "/"},
|
||||||
|
@ -1368,10 +1368,10 @@ func TestAgnosterLeftPath(t *testing.T) {
|
||||||
|
|
||||||
func TestGetPwd(t *testing.T) {
|
func TestGetPwd(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
MappedLocationsEnabled bool
|
|
||||||
Pwd string
|
Pwd string
|
||||||
Pswd string
|
Pswd string
|
||||||
Expected string
|
Expected string
|
||||||
|
MappedLocationsEnabled bool
|
||||||
}{
|
}{
|
||||||
{MappedLocationsEnabled: true, Pwd: homeDir, Expected: "~"},
|
{MappedLocationsEnabled: true, Pwd: homeDir, Expected: "~"},
|
||||||
{MappedLocationsEnabled: true, Pwd: homeDir + "-test", Expected: homeDir + "-test"},
|
{MappedLocationsEnabled: true, Pwd: homeDir + "-test", Expected: homeDir + "-test"},
|
||||||
|
@ -1604,8 +1604,8 @@ func TestReplaceMappedLocations(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Pwd string
|
Pwd string
|
||||||
MappedLocationsEnabled bool
|
|
||||||
Expected string
|
Expected string
|
||||||
|
MappedLocationsEnabled bool
|
||||||
}{
|
}{
|
||||||
{Pwd: "/c/l/k/f", Expected: "f"},
|
{Pwd: "/c/l/k/f", Expected: "f"},
|
||||||
{Pwd: "/f/g/h", Expected: "/f/g/h"},
|
{Pwd: "/f/g/h", Expected: "/f/g/h"},
|
||||||
|
@ -1721,8 +1721,8 @@ func TestSplitPath(t *testing.T) {
|
||||||
|
|
||||||
func TestGetMaxWidth(t *testing.T) {
|
func TestGetMaxWidth(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
|
||||||
MaxWidth any
|
MaxWidth any
|
||||||
|
Case string
|
||||||
Expected int
|
Expected int
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,14 +28,12 @@ func (s *PlasticStatus) add(code string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Plastic struct {
|
type Plastic struct {
|
||||||
scm
|
|
||||||
|
|
||||||
Status *PlasticStatus
|
Status *PlasticStatus
|
||||||
Behind bool
|
|
||||||
Selector string
|
Selector string
|
||||||
|
plasticWorkspaceFolder string
|
||||||
|
scm
|
||||||
|
Behind bool
|
||||||
MergePending bool
|
MergePending bool
|
||||||
|
|
||||||
plasticWorkspaceFolder string // root folder of workspace
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Plastic) Init(props properties.Properties, env runtime.Environment) {
|
func (p *Plastic) Init(props properties.Properties, env runtime.Environment) {
|
||||||
|
|
|
@ -69,9 +69,9 @@ func TestPlasticGetCmOutputForCommand(t *testing.T) {
|
||||||
func TestPlasticStatusBehind(t *testing.T) {
|
func TestPlasticStatusBehind(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Expected bool
|
|
||||||
Status string
|
Status string
|
||||||
Head string
|
Head string
|
||||||
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Not behind",
|
Case: "Not behind",
|
||||||
|
@ -97,8 +97,8 @@ func TestPlasticStatusBehind(t *testing.T) {
|
||||||
func TestPlasticStatusChanged(t *testing.T) {
|
func TestPlasticStatusChanged(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Expected bool
|
|
||||||
Status string
|
Status string
|
||||||
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "No changes",
|
Case: "No changes",
|
||||||
|
@ -164,8 +164,8 @@ func TestPlasticStatusCounts(t *testing.T) {
|
||||||
func TestPlasticMergePending(t *testing.T) {
|
func TestPlasticMergePending(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Expected bool
|
|
||||||
Status string
|
Status string
|
||||||
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "No pending merge",
|
Case: "No pending merge",
|
||||||
|
@ -188,10 +188,10 @@ func TestPlasticMergePending(t *testing.T) {
|
||||||
func TestPlasticParseIntPattern(t *testing.T) {
|
func TestPlasticParseIntPattern(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Expected int
|
|
||||||
Text string
|
Text string
|
||||||
Pattern string
|
Pattern string
|
||||||
Name string
|
Name string
|
||||||
|
Expected int
|
||||||
Default int
|
Default int
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -287,10 +287,10 @@ func TestPlasticStatus(t *testing.T) {
|
||||||
|
|
||||||
func TestPlasticTemplateString(t *testing.T) {
|
func TestPlasticTemplateString(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Plastic *Plastic
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
Template string
|
Template string
|
||||||
Plastic *Plastic
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Default template",
|
Case: "Default template",
|
||||||
|
|
|
@ -11,18 +11,18 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type poshGit struct {
|
type poshGit struct {
|
||||||
|
Index *poshGitStatus `json:"Index"`
|
||||||
|
Working *poshGitStatus `json:"Working"`
|
||||||
|
RepoName string `json:"RepoName"`
|
||||||
|
Branch string `json:"Branch"`
|
||||||
|
GitDir string `json:"GitDir"`
|
||||||
|
Upstream string `json:"Upstream"`
|
||||||
StashCount int `json:"StashCount"`
|
StashCount int `json:"StashCount"`
|
||||||
AheadBy int `json:"AheadBy"`
|
AheadBy int `json:"AheadBy"`
|
||||||
Index *poshGitStatus `json:"Index"`
|
|
||||||
RepoName string `json:"RepoName"`
|
|
||||||
HasWorking bool `json:"HasWorking"`
|
|
||||||
Branch string `json:"Branch"`
|
|
||||||
HasIndex bool `json:"HasIndex"`
|
|
||||||
GitDir string `json:"GitDir"`
|
|
||||||
BehindBy int `json:"BehindBy"`
|
BehindBy int `json:"BehindBy"`
|
||||||
|
HasWorking bool `json:"HasWorking"`
|
||||||
|
HasIndex bool `json:"HasIndex"`
|
||||||
HasUntracked bool `json:"HasUntracked"`
|
HasUntracked bool `json:"HasUntracked"`
|
||||||
Working *poshGitStatus `json:"Working"`
|
|
||||||
Upstream string `json:"Upstream"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type poshGitStatus struct {
|
type poshGitStatus struct {
|
||||||
|
|
|
@ -15,9 +15,9 @@ func TestPoshGitSegment(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
PoshGitJSON string
|
PoshGitJSON string
|
||||||
FetchUpstreamIcon bool
|
|
||||||
Template string
|
Template string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
FetchUpstreamIcon bool
|
||||||
ExpectedEnabled bool
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,9 +16,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProjectItem struct {
|
type ProjectItem struct {
|
||||||
|
Fetcher func(item ProjectItem) *ProjectData
|
||||||
Name string
|
Name string
|
||||||
Files []string
|
Files []string
|
||||||
Fetcher func(item ProjectItem) *ProjectData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProjectData struct {
|
type ProjectData struct {
|
||||||
|
@ -54,11 +54,9 @@ type NuSpec struct {
|
||||||
type Project struct {
|
type Project struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
|
|
||||||
projects []*ProjectItem
|
|
||||||
Error string
|
|
||||||
|
|
||||||
ProjectData
|
ProjectData
|
||||||
|
Error string
|
||||||
|
projects []*ProjectItem
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Project) Enabled() bool {
|
func (n *Project) Enabled() bool {
|
||||||
|
|
|
@ -19,11 +19,11 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type MockDirEntry struct {
|
type MockDirEntry struct {
|
||||||
name string
|
|
||||||
isDir bool
|
|
||||||
fileMode fs.FileMode
|
|
||||||
fileInfo fs.FileInfo
|
fileInfo fs.FileInfo
|
||||||
err error
|
err error
|
||||||
|
name string
|
||||||
|
fileMode fs.FileMode
|
||||||
|
isDir bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockDirEntry) Name() string {
|
func (m *MockDirEntry) Name() string {
|
||||||
|
@ -276,9 +276,9 @@ func TestPackage(t *testing.T) {
|
||||||
func TestNuspecPackage(t *testing.T) {
|
func TestNuspecPackage(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
HasFiles bool
|
|
||||||
FileName string
|
FileName string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
HasFiles bool
|
||||||
ExpectedEnabled bool
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -342,9 +342,9 @@ func TestDotnetProject(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
FileName string
|
FileName string
|
||||||
HasFiles bool
|
|
||||||
ProjectContents string
|
ProjectContents string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
HasFiles bool
|
||||||
ExpectedEnabled bool
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -415,8 +415,8 @@ func TestDotnetProject(t *testing.T) {
|
||||||
func TestPowerShellModuleProject(t *testing.T) {
|
func TestPowerShellModuleProject(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
HasFiles bool
|
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
HasFiles bool
|
||||||
ExpectedEnabled bool
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,25 +13,20 @@ import (
|
||||||
|
|
||||||
func TestPulumi(t *testing.T) {
|
func TestPulumi(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
StackError error
|
||||||
|
AboutError error
|
||||||
|
About string
|
||||||
YAMLConfig string
|
YAMLConfig string
|
||||||
JSONConfig string
|
JSONConfig string
|
||||||
|
Case string
|
||||||
HasCommand bool
|
|
||||||
|
|
||||||
FetchStack bool
|
|
||||||
Stack string
|
|
||||||
StackError error
|
|
||||||
|
|
||||||
HasWorkspaceFolder bool
|
|
||||||
WorkSpaceFile string
|
|
||||||
|
|
||||||
FetchAbout bool
|
|
||||||
About string
|
|
||||||
AboutError error
|
|
||||||
AboutCache string
|
|
||||||
|
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
Stack string
|
||||||
|
AboutCache string
|
||||||
|
WorkSpaceFile string
|
||||||
|
HasCommand bool
|
||||||
|
FetchAbout bool
|
||||||
|
HasWorkspaceFolder bool
|
||||||
|
FetchStack bool
|
||||||
ExpectedEnabled bool
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,9 +12,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Python struct {
|
type Python struct {
|
||||||
language
|
|
||||||
|
|
||||||
Venv string
|
Venv string
|
||||||
|
language
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -15,19 +15,19 @@ import (
|
||||||
|
|
||||||
func TestPythonTemplate(t *testing.T) {
|
func TestPythonTemplate(t *testing.T) {
|
||||||
type ResolveSymlink struct {
|
type ResolveSymlink struct {
|
||||||
Path string
|
|
||||||
Err error
|
Err error
|
||||||
|
Path string
|
||||||
}
|
}
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
ResolveSymlink ResolveSymlink
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
ExpectedDisabled bool
|
|
||||||
Template string
|
Template string
|
||||||
VirtualEnvName string
|
VirtualEnvName string
|
||||||
FetchVersion bool
|
|
||||||
PythonPath string
|
PythonPath string
|
||||||
ResolveSymlink ResolveSymlink
|
|
||||||
PyvenvCfg string
|
PyvenvCfg string
|
||||||
|
ExpectedDisabled bool
|
||||||
|
FetchVersion bool
|
||||||
}{
|
}{
|
||||||
{Case: "No virtual env present", FetchVersion: true, Expected: "3.8.4", Template: "{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}"},
|
{Case: "No virtual env present", FetchVersion: true, Expected: "3.8.4", Template: "{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}"},
|
||||||
{Case: "Virtual env present", FetchVersion: true, Expected: "VENV 3.8.4", VirtualEnvName: "VENV", Template: "{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}"},
|
{Case: "Virtual env present", FetchVersion: true, Expected: "VENV 3.8.4", VirtualEnvName: "VENV", Template: "{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}"},
|
||||||
|
@ -123,8 +123,8 @@ func TestPythonTemplate(t *testing.T) {
|
||||||
|
|
||||||
func TestPythonPythonInContext(t *testing.T) {
|
func TestPythonPythonInContext(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Expected bool
|
|
||||||
VirtualEnvName string
|
VirtualEnvName string
|
||||||
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{Expected: true, VirtualEnvName: "VENV"},
|
{Expected: true, VirtualEnvName: "VENV"},
|
||||||
{Expected: false, VirtualEnvName: ""},
|
{Expected: false, VirtualEnvName: ""},
|
||||||
|
@ -151,8 +151,8 @@ func TestPythonPythonInContext(t *testing.T) {
|
||||||
func TestPythonVirtualEnvIgnoreDefaultVenvNames(t *testing.T) {
|
func TestPythonVirtualEnvIgnoreDefaultVenvNames(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Expected string
|
Expected string
|
||||||
FolderNameFallback bool
|
|
||||||
VirtualEnvName string
|
VirtualEnvName string
|
||||||
|
FolderNameFallback bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Expected: "folder",
|
Expected: "folder",
|
||||||
|
@ -202,9 +202,9 @@ func TestPythonVirtualEnvIgnoreDefaultVenvNames(t *testing.T) {
|
||||||
func TestPythonVirtualEnvIgnoreCustomVenvNames(t *testing.T) {
|
func TestPythonVirtualEnvIgnoreCustomVenvNames(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Expected string
|
Expected string
|
||||||
FolderNameFallback bool
|
|
||||||
DefaultVenvNames []string
|
|
||||||
VirtualEnvName string
|
VirtualEnvName string
|
||||||
|
DefaultVenvNames []string
|
||||||
|
FolderNameFallback bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Expected: "folder",
|
Expected: "folder",
|
||||||
|
|
|
@ -18,11 +18,10 @@ type Package struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Quasar struct {
|
type Quasar struct {
|
||||||
language
|
|
||||||
|
|
||||||
HasVite bool
|
|
||||||
Vite *Package
|
Vite *Package
|
||||||
AppVite *Package
|
AppVite *Package
|
||||||
|
language
|
||||||
|
HasVite bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Quasar) Enabled() bool {
|
func (q *Quasar) Enabled() bool {
|
||||||
|
|
|
@ -11,10 +11,10 @@ func TestR(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
Version string
|
||||||
HasRscript bool
|
HasRscript bool
|
||||||
HasR bool
|
HasR bool
|
||||||
HasRexe bool
|
HasRexe bool
|
||||||
Version string
|
|
||||||
}{
|
}{
|
||||||
{Case: "Rscript 4.2.0", ExpectedString: "4.2.0", HasRscript: true, Version: "Rscript (R) version 4.2.0 (2022-04-22)"},
|
{Case: "Rscript 4.2.0", ExpectedString: "4.2.0", HasRscript: true, Version: "Rscript (R) version 4.2.0 (2022-04-22)"},
|
||||||
{Case: "Rscript 4.1.3", ExpectedString: "4.1.3", HasRscript: true, Version: "R scripting front-end version 4.1.3 (2022-03-10)"},
|
{Case: "Rscript 4.1.3", ExpectedString: "4.1.3", HasRscript: true, Version: "R scripting front-end version 4.1.3 (2022-03-10)"},
|
||||||
|
|
|
@ -13,12 +13,12 @@ func TestRuby(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
Version string
|
||||||
HasRbenv bool
|
HasRbenv bool
|
||||||
HasRvmprompt bool
|
HasRvmprompt bool
|
||||||
HasChruby bool
|
HasChruby bool
|
||||||
HasAsdf bool
|
HasAsdf bool
|
||||||
HasRuby bool
|
HasRuby bool
|
||||||
Version string
|
|
||||||
HasRubyFiles bool
|
HasRubyFiles bool
|
||||||
HasRakeFile bool
|
HasRakeFile bool
|
||||||
HasGemFile bool
|
HasGemFile bool
|
||||||
|
|
|
@ -44,17 +44,15 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Sapling struct {
|
type Sapling struct {
|
||||||
scm
|
Working *SaplingStatus
|
||||||
|
|
||||||
ShortHash string
|
ShortHash string
|
||||||
Hash string
|
Hash string
|
||||||
When string
|
When string
|
||||||
Author string
|
Author string
|
||||||
Bookmark string
|
Bookmark string
|
||||||
Description string
|
Description string
|
||||||
|
scm
|
||||||
New bool
|
New bool
|
||||||
|
|
||||||
Working *SaplingStatus
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sl *Sapling) Template() string {
|
func (sl *Sapling) Template() string {
|
||||||
|
|
|
@ -184,9 +184,9 @@ func TestShouldDisplay(t *testing.T) {
|
||||||
func TestSetHeadContext(t *testing.T) {
|
func TestSetHeadContext(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
FetchStatus bool
|
|
||||||
Output string
|
Output string
|
||||||
Expected string
|
Expected string
|
||||||
|
FetchStatus bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Do not fetch status",
|
Case: "Do not fetch status",
|
||||||
|
|
|
@ -18,6 +18,7 @@ const (
|
||||||
|
|
||||||
// ScmStatus represents part of the status of a repository
|
// ScmStatus represents part of the status of a repository
|
||||||
type ScmStatus struct {
|
type ScmStatus struct {
|
||||||
|
Formats map[string]string
|
||||||
Unmerged int
|
Unmerged int
|
||||||
Deleted int
|
Deleted int
|
||||||
Added int
|
Added int
|
||||||
|
@ -28,8 +29,6 @@ type ScmStatus struct {
|
||||||
Clean int
|
Clean int
|
||||||
Missing int
|
Missing int
|
||||||
Ignored int
|
Ignored int
|
||||||
|
|
||||||
Formats map[string]string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ScmStatus) Changed() bool {
|
func (s *ScmStatus) Changed() bool {
|
||||||
|
@ -83,16 +82,14 @@ func (s *ScmStatus) String() string {
|
||||||
type scm struct {
|
type scm struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
|
Dir string
|
||||||
IsWslSharedPath bool
|
|
||||||
CommandMissing bool
|
|
||||||
Dir string // actual repo root directory
|
|
||||||
RepoName string
|
RepoName string
|
||||||
|
|
||||||
workingDir string
|
workingDir string
|
||||||
rootDir string
|
rootDir string
|
||||||
realDir string // real directory (can be different from current path when in worktrees)
|
realDir string
|
||||||
command string
|
command string
|
||||||
|
IsWslSharedPath bool
|
||||||
|
CommandMissing bool
|
||||||
nativeFallback bool
|
nativeFallback bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
func TestScmStatusChanged(t *testing.T) {
|
func TestScmStatusChanged(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Expected bool
|
|
||||||
Status ScmStatus
|
Status ScmStatus
|
||||||
|
Expected bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "No changes",
|
Case: "No changes",
|
||||||
|
@ -143,12 +143,12 @@ func TestHasCommand(t *testing.T) {
|
||||||
|
|
||||||
func TestFormatBranch(t *testing.T) {
|
func TestFormatBranch(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
MappedBranches map[string]string
|
||||||
Case string
|
Case string
|
||||||
Expected string
|
Expected string
|
||||||
Input string
|
Input string
|
||||||
MappedBranches map[string]string
|
|
||||||
BranchMaxLength int
|
|
||||||
TruncateSymbol string
|
TruncateSymbol string
|
||||||
|
BranchMaxLength int
|
||||||
NoFullBranchPath bool
|
NoFullBranchPath bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,12 +9,8 @@ import (
|
||||||
type Session struct {
|
type Session struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
// text string
|
|
||||||
|
|
||||||
SSHSession bool
|
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
DefaultUserName string
|
DefaultUserName string
|
||||||
|
SSHSession bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) Enabled() bool {
|
func (s *Session) Enabled() bool {
|
||||||
|
|
|
@ -19,11 +19,11 @@ func TestSessionSegmentTemplate(t *testing.T) {
|
||||||
UserName string
|
UserName string
|
||||||
DefaultUserName string
|
DefaultUserName string
|
||||||
ComputerName string
|
ComputerName string
|
||||||
SSHSession bool
|
|
||||||
Root bool
|
|
||||||
Template string
|
Template string
|
||||||
WhoAmI string
|
WhoAmI string
|
||||||
Platform string
|
Platform string
|
||||||
|
SSHSession bool
|
||||||
|
Root bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "user and computer",
|
Case: "user and computer",
|
||||||
|
|
|
@ -28,8 +28,8 @@ type EndpointConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserConfig struct {
|
type UserConfig struct {
|
||||||
DefaultEndpoint string `json:"defaultEndpoint"`
|
|
||||||
Endpoints map[string]EndpointConfig `json:"endpoints"`
|
Endpoints map[string]EndpointConfig `json:"endpoints"`
|
||||||
|
DefaultEndpoint string `json:"defaultEndpoint"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sitecore) Enabled() bool {
|
func (s *Sitecore) Enabled() bool {
|
||||||
|
|
|
@ -15,10 +15,10 @@ func TestSitecoreSegment(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
|
UserFileContent string
|
||||||
ExpectedEnabled bool
|
ExpectedEnabled bool
|
||||||
SitecoreFileExists bool
|
SitecoreFileExists bool
|
||||||
UserFileExists bool
|
UserFileExists bool
|
||||||
UserFileContent string
|
|
||||||
DisplayDefault bool
|
DisplayDefault bool
|
||||||
}{
|
}{
|
||||||
{Case: "Disabled, no sitecore.json file and user.json file", ExpectedString: "", ExpectedEnabled: false, SitecoreFileExists: false, UserFileExists: false},
|
{Case: "Disabled, no sitecore.json file and user.json file", ExpectedString: "", ExpectedEnabled: false, SitecoreFileExists: false, UserFileExists: false},
|
||||||
|
|
|
@ -14,12 +14,12 @@ import (
|
||||||
|
|
||||||
func TestSpotifyDarwinEnabledAndSpotifyPlaying(t *testing.T) {
|
func TestSpotifyDarwinEnabledAndSpotifyPlaying(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Error error
|
||||||
Running string
|
Running string
|
||||||
Expected string
|
Expected string
|
||||||
Status string
|
Status string
|
||||||
Artist string
|
Artist string
|
||||||
Track string
|
Track string
|
||||||
Error error
|
|
||||||
}{
|
}{
|
||||||
{Running: "false", Expected: ""},
|
{Running: "false", Expected: ""},
|
||||||
{Running: "false", Expected: "", Error: errors.New("oops")},
|
{Running: "false", Expected: "", Error: errors.New("oops")},
|
||||||
|
@ -32,10 +32,12 @@ func TestSpotifyDarwinEnabledAndSpotifyPlaying(t *testing.T) {
|
||||||
env.On("RunCommand", "osascript", []string{"-e", "tell application \"Spotify\" to player state as string"}).Return(tc.Status, nil)
|
env.On("RunCommand", "osascript", []string{"-e", "tell application \"Spotify\" to player state as string"}).Return(tc.Status, nil)
|
||||||
env.On("RunCommand", "osascript", []string{"-e", "tell application \"Spotify\" to artist of current track as string"}).Return(tc.Artist, nil)
|
env.On("RunCommand", "osascript", []string{"-e", "tell application \"Spotify\" to artist of current track as string"}).Return(tc.Artist, nil)
|
||||||
env.On("RunCommand", "osascript", []string{"-e", "tell application \"Spotify\" to name of current track as string"}).Return(tc.Track, nil)
|
env.On("RunCommand", "osascript", []string{"-e", "tell application \"Spotify\" to name of current track as string"}).Return(tc.Track, nil)
|
||||||
|
|
||||||
s := &Spotify{
|
s := &Spotify{
|
||||||
env: env,
|
env: env,
|
||||||
props: properties.Map{},
|
props: properties.Map{},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, tc.Running == "true", s.Enabled())
|
assert.Equal(t, tc.Running == "true", s.Enabled())
|
||||||
assert.Equal(t, tc.Expected, renderTemplate(env, s.Template(), s))
|
assert.Equal(t, tc.Expected, renderTemplate(env, s.Template(), s))
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ import (
|
||||||
|
|
||||||
func TestSpotifyWindowsNative(t *testing.T) {
|
func TestSpotifyWindowsNative(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Error error
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
Title string
|
Title string
|
||||||
Error error
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Playing",
|
Case: "Playing",
|
||||||
|
@ -55,11 +55,11 @@ func TestSpotifyWindowsNative(t *testing.T) {
|
||||||
|
|
||||||
func TestSpotifyWindowsPWA(t *testing.T) {
|
func TestSpotifyWindowsPWA(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Error error
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
Title string
|
Title string
|
||||||
Error error
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Playing",
|
Case: "Playing",
|
||||||
|
|
|
@ -16,8 +16,8 @@ func TestSpotifyWsl(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
ExecOutput string
|
ExecOutput string
|
||||||
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Spotify not running",
|
Case: "Spotify not running",
|
||||||
|
|
|
@ -17,15 +17,11 @@ const (
|
||||||
type Status struct {
|
type Status struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
env runtime.Environment
|
env runtime.Environment
|
||||||
|
|
||||||
String string
|
|
||||||
Error bool
|
|
||||||
Code int
|
|
||||||
|
|
||||||
template *template.Text
|
template *template.Text
|
||||||
|
String string
|
||||||
// Deprecated: Use {{ reason .Code }} instead
|
|
||||||
Meaning string
|
Meaning string
|
||||||
|
Code int
|
||||||
|
Error bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Status) Template() string {
|
func (s *Status) Template() string {
|
||||||
|
|
|
@ -14,9 +14,9 @@ import (
|
||||||
|
|
||||||
func TestStatusWriterEnabled(t *testing.T) {
|
func TestStatusWriterEnabled(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
Template string
|
||||||
Status int
|
Status int
|
||||||
Expected bool
|
Expected bool
|
||||||
Template string
|
|
||||||
}{
|
}{
|
||||||
{Status: 102, Expected: true},
|
{Status: 102, Expected: true},
|
||||||
{Status: 0, Expected: false},
|
{Status: 0, Expected: false},
|
||||||
|
@ -49,11 +49,11 @@ func TestStatusWriterEnabled(t *testing.T) {
|
||||||
func TestFormatStatus(t *testing.T) {
|
func TestFormatStatus(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
Status int
|
|
||||||
PipeStatus string
|
PipeStatus string
|
||||||
Template string
|
Template string
|
||||||
Separator string
|
Separator string
|
||||||
Expected string
|
Expected string
|
||||||
|
Status int
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "No PipeStatus",
|
Case: "No PipeStatus",
|
||||||
|
|
|
@ -27,16 +27,14 @@ func (s *stravaAPI) GetActivities() ([]*StravaData, error) {
|
||||||
// segment struct, makes templating easier
|
// segment struct, makes templating easier
|
||||||
type Strava struct {
|
type Strava struct {
|
||||||
props properties.Properties
|
props properties.Properties
|
||||||
|
api StravaAPI
|
||||||
StravaData
|
|
||||||
Icon string
|
Icon string
|
||||||
Ago string
|
Ago string
|
||||||
Hours int
|
|
||||||
Authenticate bool
|
|
||||||
Error string
|
Error string
|
||||||
URL string
|
URL string
|
||||||
|
StravaData
|
||||||
api StravaAPI
|
Hours int
|
||||||
|
Authenticate bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -54,18 +52,18 @@ const (
|
||||||
|
|
||||||
// StravaData struct contains the API data
|
// StravaData struct contains the API data
|
||||||
type StravaData struct {
|
type StravaData struct {
|
||||||
ID int `json:"id"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
StartDate time.Time `json:"start_date"`
|
StartDate time.Time `json:"start_date"`
|
||||||
|
Type string `json:"type"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
ID int `json:"id"`
|
||||||
Distance float64 `json:"distance"`
|
Distance float64 `json:"distance"`
|
||||||
Duration float64 `json:"moving_time"`
|
Duration float64 `json:"moving_time"`
|
||||||
DeviceWatts bool `json:"device_watts"`
|
|
||||||
AverageWatts float64 `json:"average_watts"`
|
AverageWatts float64 `json:"average_watts"`
|
||||||
WeightedAverageWatts float64 `json:"weighted_average_watts"`
|
WeightedAverageWatts float64 `json:"weighted_average_watts"`
|
||||||
AverageHeartRate float64 `json:"average_heartrate"`
|
AverageHeartRate float64 `json:"average_heartrate"`
|
||||||
MaxHeartRate float64 `json:"max_heartrate"`
|
MaxHeartRate float64 `json:"max_heartrate"`
|
||||||
KudosCount int `json:"kudos_count"`
|
KudosCount int `json:"kudos_count"`
|
||||||
|
DeviceWatts bool `json:"device_watts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Strava) Template() string {
|
func (s *Strava) Template() string {
|
||||||
|
|
|
@ -28,12 +28,12 @@ func TestStravaSegment(t *testing.T) {
|
||||||
fourDaysAgo := time.Now().Add(-h)
|
fourDaysAgo := time.Now().Add(-h)
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
|
APIError error
|
||||||
Case string
|
Case string
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
|
||||||
Template string
|
Template string
|
||||||
APIError error
|
|
||||||
StravaData []*StravaData
|
StravaData []*StravaData
|
||||||
|
ExpectedEnabled bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "Ride 6",
|
Case: "Ride 6",
|
||||||
|
|
|
@ -39,11 +39,10 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Svn struct {
|
type Svn struct {
|
||||||
scm
|
|
||||||
|
|
||||||
Working *SvnStatus
|
Working *SvnStatus
|
||||||
BaseRev int
|
|
||||||
Branch string
|
Branch string
|
||||||
|
scm
|
||||||
|
BaseRev int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Svn) Template() string {
|
func (s *Svn) Template() string {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue