Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix unit tests
  • Loading branch information
Emyrk committed Apr 4, 2023
commit 440645cfc459052843d69ba9dc4af006cd38171e
8 changes: 3 additions & 5 deletions coderd/database/dbauthz/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,9 @@ func (s *MethodTestSuite) TestOrganization() {

func (s *MethodTestSuite) TestWorkspaceProxy() {
s.Run("InsertWorkspaceProxy", s.Subtest(func(db database.Store, check *expects) {
o := dbgen.Organization(s.T(), db, database.Organization{})
check.Args(database.InsertWorkspaceProxyParams{
ID: uuid.New(),
OrganizationID: o.ID,
}).Asserts(rbac.ResourceWorkspaceProxy.InOrg(o.ID), rbac.ActionCreate)
ID: uuid.New(),
}).Asserts(rbac.ResourceWorkspaceProxy, rbac.ActionCreate)
}))
s.Run("UpdateWorkspaceProxy", s.Subtest(func(db database.Store, check *expects) {
p := dbgen.WorkspaceProxy(s.T(), db, database.WorkspaceProxy{})
Expand All @@ -464,7 +462,7 @@ func (s *MethodTestSuite) TestWorkspaceProxy() {
}).Asserts(p, rbac.ActionDelete)
}))
s.Run("GetWorkspaceProxies", s.Subtest(func(db database.Store, check *expects) {
p1 := dbgen.WorkspaceProxy(s.T(), db, database.WorkspacseProxy{})
p1 := dbgen.WorkspaceProxy(s.T(), db, database.WorkspaceProxy{})
p2 := dbgen.WorkspaceProxy(s.T(), db, database.WorkspaceProxy{})
check.Args().Asserts(p1, rbac.ActionRead, p2, rbac.ActionRead).Returns(slice.New(p1, p2))
}))
Expand Down
8 changes: 4 additions & 4 deletions codersdk/workspaceproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ type WorkspaceProxy struct {
Deleted bool `db:"deleted" json:"deleted"`
}

func (c *Client) CreateWorkspaceProxy(ctx context.Context, orgID uuid.UUID, req CreateWorkspaceProxyRequest) (WorkspaceProxy, error) {
func (c *Client) CreateWorkspaceProxy(ctx context.Context, req CreateWorkspaceProxyRequest) (WorkspaceProxy, error) {
res, err := c.Request(ctx, http.MethodPost,
fmt.Sprintf("/api/v2/organizations/%s/workspaceproxies", orgID.String()),
fmt.Sprintf("/api/v2/workspaceproxies"),
req,
)
if err != nil {
Expand All @@ -51,9 +51,9 @@ func (c *Client) CreateWorkspaceProxy(ctx context.Context, orgID uuid.UUID, req
return resp, json.NewDecoder(res.Body).Decode(&resp)
}

func (c *Client) WorkspaceProxiesByOrganization(ctx context.Context, orgID uuid.UUID) ([]WorkspaceProxy, error) {
func (c *Client) WorkspaceProxiesByOrganization(ctx context.Context) ([]WorkspaceProxy, error) {
res, err := c.Request(ctx, http.MethodGet,
fmt.Sprintf("/api/v2/organizations/%s/workspaceproxies", orgID.String()),
fmt.Sprintf("/api/v2/workspaceproxies"),
nil,
)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions enterprise/coderd/workspaceproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ func TestWorkspaceProxyCRUD(t *testing.T) {
DeploymentValues: dv,
},
})
user := coderdtest.CreateFirstUser(t, client)
_ = coderdtest.CreateFirstUser(t, client)
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureWorkspaceProxy: 1,
},
})
ctx := testutil.Context(t, testutil.WaitLong)
proxy, err := client.CreateWorkspaceProxy(ctx, user.OrganizationID, codersdk.CreateWorkspaceProxyRequest{
proxy, err := client.CreateWorkspaceProxy(ctx, codersdk.CreateWorkspaceProxyRequest{
Name: namesgenerator.GetRandomName(1),
Icon: "/emojis/flag.png",
URL: "https://" + namesgenerator.GetRandomName(1) + ".com",
WildcardHostname: "*." + namesgenerator.GetRandomName(1) + ".com",
})
require.NoError(t, err)

proxies, err := client.WorkspaceProxiesByOrganization(ctx, user.OrganizationID)
proxies, err := client.WorkspaceProxiesByOrganization(ctx)
require.NoError(t, err)
require.Len(t, proxies, 1)
require.Equal(t, proxy, proxies[0])
Expand Down