|
5 | 5 | "testing" |
6 | 6 |
|
7 | 7 | "github.com/docker/docker/client" |
| 8 | + "github.com/jesseduffield/lazydocker/pkg/config" |
8 | 9 | "github.com/stretchr/testify/assert" |
9 | 10 | ) |
10 | 11 |
|
@@ -61,3 +62,30 @@ func TestNewDockerClientVersionNegotiation(t *testing.T) { |
61 | 62 | "client version should not be locked to DOCKER_API_VERSION env var") |
62 | 63 | }) |
63 | 64 | } |
| 65 | + |
| 66 | +// TestIsProjectScoped covers the predicate that drives whether the |
| 67 | +// project/services panels appear and whether the containers panel filters by |
| 68 | +// project. The "outside compose dir + -p" case is the regression we fixed |
| 69 | +// after PR #776 silently disabled it. |
| 70 | +func TestIsProjectScoped(t *testing.T) { |
| 71 | + cases := []struct { |
| 72 | + name string |
| 73 | + inDockerComposeProject bool |
| 74 | + projectName string |
| 75 | + want bool |
| 76 | + }{ |
| 77 | + {"inside compose dir, no -p", true, "", true}, |
| 78 | + {"inside compose dir, with -p", true, "myproject", true}, |
| 79 | + {"outside compose dir, no -p", false, "", false}, |
| 80 | + {"outside compose dir, with -p", false, "myproject", true}, |
| 81 | + } |
| 82 | + for _, tc := range cases { |
| 83 | + t.Run(tc.name, func(t *testing.T) { |
| 84 | + c := &DockerCommand{ |
| 85 | + InDockerComposeProject: tc.inDockerComposeProject, |
| 86 | + Config: &config.AppConfig{ProjectName: tc.projectName}, |
| 87 | + } |
| 88 | + assert.Equal(t, tc.want, c.IsProjectScoped()) |
| 89 | + }) |
| 90 | + } |
| 91 | +} |
0 commit comments