MCPcopy Index your code
hub / github.com/coder/coder / TestUpdateRoleSync

Function TestUpdateRoleSync

enterprise/cli/organizationsettings_test.go:71–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestUpdateRoleSync(t *testing.T) {
72 t.Parallel()
73
74 t.Run("OK", func(t *testing.T) {
75 t.Parallel()
76
77 owner, _ := coderdenttest.New(t, &coderdenttest.Options{
78 LicenseOptions: &coderdenttest.LicenseOptions{
79 Features: license.Features{
80 codersdk.FeatureMultipleOrganizations: 1,
81 },
82 },
83 })
84
85 ctx := testutil.Context(t, testutil.WaitLong)
86 inv, root := clitest.New(t, "organization", "settings", "set", "rolesync")
87 //nolint:gocritic // Using the owner, testing the cli not perms
88 clitest.SetupConfig(t, owner, root)
89
90 expectedSettings := codersdk.RoleSyncSettings{
91 Field: "roles",
92 Mapping: map[string][]string{
93 "test": {rbac.RoleOrgAdmin()},
94 },
95 }
96 expectedData, err := json.Marshal(expectedSettings)
97 require.NoError(t, err)
98
99 buf := new(bytes.Buffer)
100 inv.Stdout = buf
101 inv.Stdin = bytes.NewBuffer(expectedData)
102 err = inv.WithContext(ctx).Run()
103 require.NoError(t, err)
104 require.JSONEq(t, string(expectedData), buf.String())
105
106 // Now read it back
107 inv, root = clitest.New(t, "organization", "settings", "show", "rolesync")
108 //nolint:gocritic // Using the owner, testing the cli not perms
109 clitest.SetupConfig(t, owner, root)
110
111 buf = new(bytes.Buffer)
112 inv.Stdout = buf
113 err = inv.WithContext(ctx).Run()
114 require.NoError(t, err)
115 require.JSONEq(t, string(expectedData), buf.String())
116 })
117}
118
119func TestUpdateOrganizationSync(t *testing.T) {
120 t.Parallel()

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
ContextFunction · 0.92
NewFunction · 0.92
SetupConfigFunction · 0.92
RoleOrgAdminFunction · 0.92
WithContextMethod · 0.80
RunMethod · 0.65
MarshalMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected