Skip to content

Commit 98b7c99

Browse files
authored
fix: various edge cases (#45)
* fix: various edge cases test: add tea unit test * chore: lint * chore: 🤷 * test: fail after 1 minute * test: print buffer * test: fuck windows
1 parent 5f2e60a commit 98b7c99

File tree

13 files changed

+455
-604
lines changed

13 files changed

+455
-604
lines changed

.github/workflows/push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ jobs:
8888
run: go generate -tags tools -x ./...
8989

9090
- name: Test
91-
run: go test -v ./...
91+
run: go test -race -v ./...
9292
env:
9393
SF_DEDICATED_SERVER: ${{ github.workspace }}/SatisfactoryDedicatedServer

cli/context.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ func InitCLI(apiOnly bool) (*GlobalContext, error) {
6464
return globalContext, nil
6565
}
6666

67+
// ReInit will initialize the context
68+
//
69+
// Used only by tests
70+
func (g *GlobalContext) ReInit() error {
71+
profiles, err := InitProfiles()
72+
if err != nil {
73+
return errors.Wrap(err, "failed to initialize profiles")
74+
}
75+
76+
installations, err := InitInstallations()
77+
if err != nil {
78+
return errors.Wrap(err, "failed to initialize installations")
79+
}
80+
81+
g.Installations = installations
82+
g.Profiles = profiles
83+
84+
return g.Save()
85+
}
86+
6787
// Wipe will remove any trace of ficsit anywhere
6888
func (g *GlobalContext) Wipe() error {
6989
// Wipe all installations

cli/installations_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ func TestAddInstallation(t *testing.T) {
2323
ctx, err := InitCLI(false)
2424
testza.AssertNoError(t, err)
2525

26+
err = ctx.Wipe()
27+
testza.AssertNoError(t, err)
28+
29+
err = ctx.ReInit()
30+
testza.AssertNoError(t, err)
31+
2632
ctx.Provider = MockProvider{}
2733

2834
profileName := "InstallationTest"

cli/platforms.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,15 @@ var platforms = []Platform{
2424
LockfilePath: filepath.Join("FactoryGame", "Mods"),
2525
TargetName: "Windows",
2626
},
27+
// Update 9 stuff below
28+
{
29+
VersionPath: filepath.Join("Engine", "Binaries", "Linux", "FactoryServer-Linux-Shipping.version"),
30+
LockfilePath: filepath.Join("FactoryGame", "Mods"),
31+
TargetName: "LinuxServer",
32+
},
33+
{
34+
VersionPath: filepath.Join("Engine", "Binaries", "Win64", "FactoryServer-Win64-Shipping.version"),
35+
LockfilePath: filepath.Join("FactoryGame", "Mods"),
36+
TargetName: "WindowsServer",
37+
},
2738
}

cli/test_helpers.go

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli
22

33
import (
44
"context"
5+
"time"
56

67
"github.com/satisfactorymodding/ficsit-cli/cli/provider"
78
"github.com/satisfactorymodding/ficsit-cli/ficsit"
@@ -11,9 +12,58 @@ var _ provider.Provider = (*MockProvider)(nil)
1112

1213
type MockProvider struct{}
1314

14-
func (m MockProvider) Mods(_ context.Context, _ ficsit.ModFilter) (*ficsit.ModsResponse, error) {
15-
// Currently used only by TUI
16-
return nil, nil
15+
func (m MockProvider) Mods(_ context.Context, f ficsit.ModFilter) (*ficsit.ModsResponse, error) {
16+
if f.Offset > 0 {
17+
return &ficsit.ModsResponse{
18+
Mods: ficsit.ModsModsGetMods{
19+
Count: 5,
20+
Mods: []ficsit.ModsModsGetModsModsMod{},
21+
},
22+
}, nil
23+
}
24+
25+
return &ficsit.ModsResponse{
26+
Mods: ficsit.ModsModsGetMods{
27+
Count: 5,
28+
Mods: []ficsit.ModsModsGetModsModsMod{
29+
{
30+
Id: "9LguyCdDUrpT9N",
31+
Name: "Ficsit Remote Monitoring",
32+
Mod_reference: "FicsitRemoteMonitoring",
33+
Last_version_date: time.Now(),
34+
Created_at: time.Now(),
35+
},
36+
{
37+
Id: "DGiLzB3ZErWu2V",
38+
Name: "Refined Power",
39+
Mod_reference: "RefinedPower",
40+
Last_version_date: time.Now(),
41+
Created_at: time.Now(),
42+
},
43+
{
44+
Id: "B24emzbs6xVZQr",
45+
Name: "RefinedRDLib",
46+
Mod_reference: "RefinedRDLib",
47+
Last_version_date: time.Now(),
48+
Created_at: time.Now(),
49+
},
50+
{
51+
Id: "6vQ6ckVYFiidDh",
52+
Name: "Area Actions",
53+
Mod_reference: "AreaActions",
54+
Last_version_date: time.Now(),
55+
Created_at: time.Now(),
56+
},
57+
{
58+
Id: "As2uJmQLLxjXLG",
59+
Name: "ModularUI",
60+
Mod_reference: "ModularUI",
61+
Last_version_date: time.Now(),
62+
Created_at: time.Now(),
63+
},
64+
},
65+
},
66+
}, nil
1767
}
1868

1969
func (m MockProvider) GetMod(_ context.Context, _ string) (*ficsit.GetModResponse, error) {

go.mod

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@ module github.com/satisfactorymodding/ficsit-cli
33
go 1.21
44

55
require (
6-
github.com/JohannesKaufmann/html-to-markdown v1.3.6
7-
github.com/Khan/genqlient v0.5.0
6+
github.com/JohannesKaufmann/html-to-markdown v1.4.2
7+
github.com/Khan/genqlient v0.6.0
88
github.com/MarvinJWendt/testza v0.5.2
9-
github.com/Masterminds/semver/v3 v3.2.1
10-
github.com/PuerkitoBio/goquery v1.8.0
11-
github.com/charmbracelet/bubbles v0.14.0
12-
github.com/charmbracelet/bubbletea v0.22.1
13-
github.com/charmbracelet/glamour v0.5.0
14-
github.com/charmbracelet/lipgloss v0.6.0
15-
github.com/jlaffaye/ftp v0.1.0
9+
github.com/PuerkitoBio/goquery v1.8.1
10+
github.com/charmbracelet/bubbles v0.16.1
11+
github.com/charmbracelet/bubbletea v0.24.2
12+
github.com/charmbracelet/glamour v0.6.0
13+
github.com/charmbracelet/lipgloss v0.9.1
14+
github.com/charmbracelet/x/exp/teatest v0.0.0-20231206171822-6e7b9b308fe7
15+
github.com/jlaffaye/ftp v0.2.0
1616
github.com/mircearoata/pubgrub-go v0.3.3
1717
github.com/muesli/reflow v0.3.0
1818
github.com/pkg/errors v0.9.1
19-
github.com/pterm/pterm v0.12.67
19+
github.com/pterm/pterm v0.12.71
2020
github.com/puzpuzpuz/xsync/v3 v3.0.2
21-
github.com/rs/zerolog v1.28.0
21+
github.com/rs/zerolog v1.31.0
2222
github.com/sahilm/fuzzy v0.1.0
23-
github.com/spf13/cobra v1.6.0
24-
github.com/spf13/viper v1.13.0
25-
golang.org/x/sync v0.1.0
23+
github.com/spf13/cobra v1.8.0
24+
github.com/spf13/viper v1.18.0
25+
golang.org/x/sync v0.5.0
2626
)
2727

2828
require (
@@ -34,56 +34,60 @@ require (
3434
github.com/alecthomas/chroma v0.10.0 // indirect
3535
github.com/alexflint/go-arg v1.4.3 // indirect
3636
github.com/alexflint/go-scalar v1.2.0 // indirect
37-
github.com/andybalholm/cascadia v1.3.1 // indirect
37+
github.com/andybalholm/cascadia v1.3.2 // indirect
3838
github.com/atotto/clipboard v0.1.4 // indirect
39-
github.com/aymanbagabas/go-osc52 v1.2.1 // indirect
39+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
40+
github.com/aymanbagabas/go-udiff v0.1.0 // indirect
4041
github.com/aymerick/douceur v0.2.0 // indirect
4142
github.com/charmbracelet/harmonica v0.2.0 // indirect
42-
github.com/containerd/console v1.0.3 // indirect
43-
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
44-
github.com/davecgh/go-spew v1.1.1 // indirect
45-
github.com/dlclark/regexp2 v1.7.0 // indirect
46-
github.com/fsnotify/fsnotify v1.6.0 // indirect
43+
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
44+
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
45+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
46+
github.com/dlclark/regexp2 v1.10.0 // indirect
47+
github.com/fsnotify/fsnotify v1.7.0 // indirect
4748
github.com/gookit/color v1.5.4 // indirect
48-
github.com/gorilla/css v1.0.0 // indirect
49+
github.com/gorilla/css v1.0.1 // indirect
4950
github.com/hashicorp/errwrap v1.1.0 // indirect
5051
github.com/hashicorp/go-multierror v1.1.1 // indirect
5152
github.com/hashicorp/hcl v1.0.0 // indirect
52-
github.com/inconshreveable/mousetrap v1.0.1 // indirect
53-
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
53+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
54+
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
5455
github.com/lithammer/fuzzysearch v1.1.8 // indirect
5556
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
56-
github.com/magiconair/properties v1.8.6 // indirect
57+
github.com/magiconair/properties v1.8.7 // indirect
5758
github.com/mattn/go-colorable v0.1.13 // indirect
58-
github.com/mattn/go-isatty v0.0.16 // indirect
59+
github.com/mattn/go-isatty v0.0.20 // indirect
5960
github.com/mattn/go-localereader v0.0.1 // indirect
6061
github.com/mattn/go-runewidth v0.0.15 // indirect
61-
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
62+
github.com/microcosm-cc/bluemonday v1.0.26 // indirect
6263
github.com/mitchellh/mapstructure v1.5.0 // indirect
63-
github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 // indirect
64+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
6465
github.com/muesli/cancelreader v0.2.2 // indirect
65-
github.com/muesli/termenv v0.13.0 // indirect
66+
github.com/muesli/termenv v0.15.2 // indirect
6667
github.com/olekukonko/tablewriter v0.0.5 // indirect
67-
github.com/pelletier/go-toml v1.9.5 // indirect
68-
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
68+
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
6969
github.com/rivo/uniseg v0.4.4 // indirect
7070
github.com/russross/blackfriday/v2 v2.1.0 // indirect
71+
github.com/sagikazarmark/locafero v0.4.0 // indirect
72+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
7173
github.com/sergi/go-diff v1.3.1 // indirect
72-
github.com/spf13/afero v1.9.2 // indirect
73-
github.com/spf13/cast v1.5.0 // indirect
74-
github.com/spf13/jwalterweatherman v1.1.0 // indirect
74+
github.com/sourcegraph/conc v0.3.0 // indirect
75+
github.com/spf13/afero v1.11.0 // indirect
76+
github.com/spf13/cast v1.6.0 // indirect
7577
github.com/spf13/pflag v1.0.5 // indirect
76-
github.com/subosito/gotenv v1.4.1 // indirect
77-
github.com/vektah/gqlparser/v2 v2.5.1 // indirect
78+
github.com/subosito/gotenv v1.6.0 // indirect
79+
github.com/vektah/gqlparser/v2 v2.5.10 // indirect
7880
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
79-
github.com/yuin/goldmark v1.5.2 // indirect
80-
github.com/yuin/goldmark-emoji v1.0.1 // indirect
81-
golang.org/x/mod v0.8.0 // indirect
82-
golang.org/x/net v0.6.0 // indirect
83-
golang.org/x/sys v0.12.0 // indirect
84-
golang.org/x/term v0.12.0 // indirect
85-
golang.org/x/text v0.13.0 // indirect
86-
golang.org/x/tools v0.6.0 // indirect
81+
github.com/yuin/goldmark v1.6.0 // indirect
82+
github.com/yuin/goldmark-emoji v1.0.2 // indirect
83+
go.uber.org/multierr v1.11.0 // indirect
84+
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect
85+
golang.org/x/mod v0.14.0 // indirect
86+
golang.org/x/net v0.19.0 // indirect
87+
golang.org/x/sys v0.15.0 // indirect
88+
golang.org/x/term v0.15.0 // indirect
89+
golang.org/x/text v0.14.0 // indirect
90+
golang.org/x/tools v0.16.0 // indirect
8791
gopkg.in/ini.v1 v1.67.0 // indirect
8892
gopkg.in/yaml.v2 v2.4.0 // indirect
8993
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)