Skip to content

Commit 4da1bce

Browse files
test: add coverage for stop.go Apple container runtime paths
- Add mockable variables for stopAppleAnalyticsForwarders, listProjectVolumes, dockerRemoveAll - Test that StopAppleAnalyticsForwarders is called on Apple runtime - Test that Docker volume suggestions are shown on Docker runtime - Test that Apple container volume suggestions are shown on Apple runtime - Test correct ordering: forwarders stopped before containers Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent eadf34f commit 4da1bce

File tree

2 files changed

+197
-211
lines changed

2 files changed

+197
-211
lines changed

internal/stop/stop.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import (
1111
"github.com/supabase/cli/internal/utils/flags"
1212
)
1313

14+
var (
15+
stopAppleAnalyticsForwarders = utils.StopAppleAnalyticsForwarders
16+
listProjectVolumes = utils.ListProjectVolumes
17+
dockerRemoveAll = utils.DockerRemoveAll
18+
)
19+
1420
func Run(ctx context.Context, backup bool, projectId string, all bool, fsys afero.Fs) error {
1521
var searchProjectIdFilter string
1622
if !all {
@@ -23,7 +29,7 @@ func Run(ctx context.Context, backup bool, projectId string, all bool, fsys afer
2329
searchProjectIdFilter = utils.Config.ProjectId
2430
}
2531
if utils.UsesAppleContainerRuntime() {
26-
if err := utils.StopAppleAnalyticsForwarders(fsys); err != nil {
32+
if err := stopAppleAnalyticsForwarders(fsys); err != nil {
2733
return err
2834
}
2935
}
@@ -37,7 +43,7 @@ func Run(ctx context.Context, backup bool, projectId string, all bool, fsys afer
3743
}
3844

3945
fmt.Println("Stopped " + utils.Aqua("supabase") + " local development setup.")
40-
if volumes, err := utils.ListProjectVolumes(ctx, searchProjectIdFilter); err == nil && len(volumes) > 0 {
46+
if volumes, err := listProjectVolumes(ctx, searchProjectIdFilter); err == nil && len(volumes) > 0 {
4147
if len(searchProjectIdFilter) > 0 {
4248
if utils.UsesAppleContainerRuntime() {
4349
listVolume := fmt.Sprintf("container volume list --format json | jq '.[] | select(.labels.\"%s\" == \"%s\")'", utils.CliProjectLabel, searchProjectIdFilter)
@@ -61,5 +67,5 @@ func Run(ctx context.Context, backup bool, projectId string, all bool, fsys afer
6167

6268
func stop(ctx context.Context, backup bool, w io.Writer, projectId string) error {
6369
utils.NoBackupVolume = !backup
64-
return utils.DockerRemoveAll(ctx, w, projectId)
70+
return dockerRemoveAll(ctx, w, projectId)
6571
}

0 commit comments

Comments
 (0)