Skip to content

Commit 2167c63

Browse files
committed
address linter complaints in provisionerdaemons_test, increase test coverage
1 parent 39dde8b commit 2167c63

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

enterprise/cli/provisionerdaemons_test.go

+38-13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/stretchr/testify/require"
88

99
"github.com/coder/coder/v2/cli/clitest"
10+
"github.com/coder/coder/v2/coderd/coderdtest"
1011
"github.com/coder/coder/v2/codersdk"
1112
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
1213
"github.com/coder/coder/v2/enterprise/coderd/license"
@@ -37,20 +38,44 @@ func TestProvisionerDaemon_PSK(t *testing.T) {
3738

3839
func TestProvisionerDaemon_SessionToken(t *testing.T) {
3940
t.Parallel()
41+
t.Run("ScopeUser", func(t *testing.T) {
42+
t.Parallel()
43+
client, admin := coderdenttest.New(t, &coderdenttest.Options{
44+
ProvisionerDaemonPSK: "provisionersftw",
45+
LicenseOptions: &coderdenttest.LicenseOptions{
46+
Features: license.Features{
47+
codersdk.FeatureExternalProvisionerDaemons: 1,
48+
},
49+
},
50+
})
51+
anotherClient, _ := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID)
52+
inv, conf := newCLI(t, "provisionerd", "start", "--tag", "scope=user")
53+
clitest.SetupConfig(t, anotherClient, conf)
54+
pty := ptytest.New(t).Attach(inv)
55+
ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong)
56+
defer cancel()
57+
clitest.Start(t, inv)
58+
pty.ExpectMatchContext(ctx, "starting provisioner daemon")
59+
})
4060

41-
client, _ := coderdenttest.New(t, &coderdenttest.Options{
42-
ProvisionerDaemonPSK: "provisionersftw",
43-
LicenseOptions: &coderdenttest.LicenseOptions{
44-
Features: license.Features{
45-
codersdk.FeatureExternalProvisionerDaemons: 1,
61+
t.Run("ScopeOrg", func(t *testing.T) {
62+
t.Parallel()
63+
client, admin := coderdenttest.New(t, &coderdenttest.Options{
64+
ProvisionerDaemonPSK: "provisionersftw",
65+
LicenseOptions: &coderdenttest.LicenseOptions{
66+
Features: license.Features{
67+
codersdk.FeatureExternalProvisionerDaemons: 1,
68+
},
4669
},
47-
},
70+
})
71+
anotherClient, _ := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID)
72+
inv, conf := newCLI(t, "provisionerd", "start", "--tag", "scope=organization")
73+
clitest.SetupConfig(t, anotherClient, conf)
74+
pty := ptytest.New(t).Attach(inv)
75+
ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong)
76+
defer cancel()
77+
clitest.Start(t, inv)
78+
pty.ExpectMatchContext(ctx, "starting provisioner daemon")
4879
})
49-
inv, conf := newCLI(t, "provisionerd", "start")
50-
clitest.SetupConfig(t, client, conf)
51-
pty := ptytest.New(t).Attach(inv)
52-
ctx, cancel := context.WithTimeout(inv.Context(), testutil.WaitLong)
53-
defer cancel()
54-
clitest.Start(t, inv)
55-
pty.ExpectMatchContext(ctx, "starting provisioner daemon")
80+
5681
}

0 commit comments

Comments
 (0)